Wysłany: 2012-04-01, 14:36
Bogdan121
Wiek: 39 Na forum: 5184 dni Posty: 41
Mam problem ze skryptem wi?zienia , mianowicie nie dzia?? komenda /arrest i nie wiem w czym lezy problem, je?li jest kto? kto mo?e mi pom?c , prosz? o odpowied? wy?l? kod skryptu poniewa? tu nie chce wej??.
Wysłany: 2012-04-01, 14:38
bentaleb
Wiek: 30 Na forum: 5399 dni Posty: 35
Nick w MP: Who Knows?
Piwa : 45
Bogdan121 , Podaj kod skryptu to ?atwiej b?dzie ci pom?c.
Wysłany: 2012-04-01, 14:39
Bogdan121
Wiek: 39 Na forum: 5184 dni Posty: 41
Kod: -- cells
cells =
{
createColSphere( 227.5, 114.7, 999.02, 2 ),
createColSphere( 223.5, 114.7, 999.02, 2 ),
createColSphere( 219.5, 114.7, 999.02, 2 ),
createColSphere( 215.5, 114.7, 999.02, 2 ),
createColSphere( 227.5, 114.7, 999.02, 2 ),
createColSphere( 223.5, 114.7, 999.02, 2 ),
createColSphere( 219.5, 114.7, 999.02, 2 ),
createColSphere( 215.5, 114.7, 999.02, 2 ),
}
for k, v in pairs( cells ) do
setElementInterior( v, 10 )
setElementDimension( v, k <= 4 and 1 or 10583 )
end
function isInArrestColshape( thePlayer )
for k, v in pairs( cells ) do
if isElementWithinColShape( thePlayer, v ) and getElementDimension( thePlayer ) == getElementDimension( v ) then
return k
end
end
return false
end
function destroyJailTimer ( ) -- 0001290: PD /release bug
local theMagicTimer = getElementData(source, "pd.jailtimer") -- 0001290: PD /release bug
if (isTimer(theMagicTimer)) then
killTimer(theMagicTimer)
exports['anticheat-system']:changeProtectedElementDataEx(source, "pd.jailserved", 0, false)
exports['anticheat-system']:changeProtectedElementDataEx(source, "pd.jailtime", 0, false)
exports['anticheat-system']:changeProtectedElementDataEx(source, "pd.jailtimer")
exports['anticheat-system']:changeProtectedElementDataEx(source, "pd.jailstation")
end
end
addEventHandler ( "onPlayerQuit", getRootElement(), destroyJailTimer )
-- /arrest
function arrestPlayer(thePlayer, commandName, targetPlayerNick, fine, jailtime, ...)
local logged = getElementData(thePlayer, "loggedin")
if (logged==1) then
local theTeam = getPlayerTeam(thePlayer)
local factionType = getElementData(theTeam, "type")
if (jailtime) then
jailtime = tonumber(jailtime)
end
local playerCol = isInArrestColshape(thePlayer)
if (factionType==2) and playerCol then
if not (targetPlayerNick) or not (fine) or not (jailtime) or not (...) or (jailtime<1) or (jailtime>9999999) then
outputChatBox("SYNTAX: /arrest [Player Partial Nick / ID] [Fine] [Jail Time (Minutes 1->9999999)] [Crimes Committed]", thePlayer, 255, 194, 14)
else
local targetPlayer, targetPlayerNick = exports.global:findPlayerByPartialNick(thePlayer, targetPlayerNick)
if targetPlayer then
local targetCol = isInArrestColshape(targetPlayer)
if not targetCol then
outputChatBox("The player is not within range of the booking desk.", thePlayer, 255, 0, 0)
elseif targetCol ~= playerCol then
outputChatBox("The player is standing infront of another cell.", thePlayer, 255, 0, 0)
else
local jailTimer = getElementData(targetPlayer, "pd.jailtimer")
local username = getPlayerName(thePlayer)
local reason = table.concat({...}, " ")
if (jailTimer) then
outputChatBox("This player is already serving a jail sentance.", thePlayer, 255, 0, 0)
else
local finebank = false
local targetPlayerhasmoney = exports.global:getMoney(targetPlayer, true)
local amount = tonumber(fine)
if not exports.global:takeMoney(targetPlayer, amount) then
finebank = true
exports.global:takeMoney(targetPlayer, targetPlayerhasmoney)
local fineleft = amount - targetPlayerhasmoney
local bankmoney = getElementData(targetPlayer, "bankmoney")
exports['anticheat-system']:changeProtectedElementDataEx(targetPlayer, "bankmoney", bankmoney-fineleft)
end
local theTimer = setTimer(timerPDUnjailPlayer, 60000, 1, targetPlayer)
exports['anticheat-system']:changeProtectedElementDataEx(targetPlayer, "pd.jailserved", 0, false)
exports['anticheat-system']:changeProtectedElementDataEx(targetPlayer, "pd.jailtime", jailtime, false)
exports['anticheat-system']:changeProtectedElementDataEx(targetPlayer, "pd.jailtimer", theTimer, false)
toggleControl(targetPlayer,'next_weapon',false)
toggleControl(targetPlayer,'previous_weapon',false)
toggleControl(targetPlayer,'fire',false)
toggleControl(targetPlayer,'aim_weapon',false)
-- auto-uncuff
local restrainedObj = getElementData(targetPlayer, "restrainedObj")
if restrainedObj then
toggleControl(targetPlayer, "sprint", true)
toggleControl(targetPlayer, "jump", true)
toggleControl(targetPlayer, "accelerate", true)
toggleControl(targetPlayer, "brake_reverse", true)
exports['anticheat-system']:changeProtectedElementDataEx(targetPlayer, "restrain", 0)
exports['anticheat-system']:changeProtectedElementDataEx(targetPlayer, "restrainedBy")
exports['anticheat-system']:changeProtectedElementDataEx(targetPlayer, "restrainedObj")
if restrainedObj == 45 then -- If handcuffs.. take the key
local dbid = getElementData(targetPlayer, "dbid")
exports['item-system']:deleteAll(47, dbid)
end
exports.global:giveItem(thePlayer, restrainedObj, 1)
mysql:query_free("UPDATE characters SET cuffed = 0, restrainedby = 0, restrainedobj = 0 WHERE id = " .. mysql:escape_string(getElementData( targetPlayer, "dbid" )) )
end
setPedWeaponSlot(targetPlayer,0)
exports['anticheat-system']:changeProtectedElementDataEx(targetPlayer, "pd.jailstation", targetCol)
mysql:query_free("UPDATE characters SET pdjail='1', pdjail_time='" .. mysql:escape_string(jailtime) .. "', pdjail_station='" .. mysql:escape_string(targetCol) .. "', cuffed = 0, restrainedby = 0, restrainedobj = 0 WHERE id = " .. mysql:escape_string(getElementData( targetPlayer, "dbid" )) )
outputChatBox("You jailed " .. targetPlayerNick .. " for " .. jailtime .. " Minutes.", thePlayer, 255, 0, 0)
local x, y, z = getElementPosition(cells[targetCol])
setElementPosition(targetPlayer, x, y - 5, z)
setPedRotation(targetPlayer, 0)
-- Trigger the event
exports.global:givePlayerAchievement(thePlayer, 7)
exports.global:givePlayerAchievement(targetPlayer, 8)
-- Show the message to the faction
local theTeam = getTeamFromName("Policja")
local teamPlayers = getPlayersInTeam(theTeam)
local factionID = getElementData(thePlayer, "faction")
local factionRank = getElementData(thePlayer, "factionrank")
local factionRanks = getElementData(theTeam, "ranks")
local factionRankTitle = factionRanks[factionRank]
outputChatBox("Zostales aresztowany przez " .. username .. " na " .. jailtime .. " minut(s).", targetPlayer, 0, 102, 255)
outputChatBox("Przestepstwa popelnione: " .. reason .. ".", targetPlayer, 0, 102, 255)
if (finebank == true) then
outputChatBox("The rest of the fine has been taken from your banking account.", targetPlayer, 0, 102, 255)
end
for key, value in ipairs(teamPlayers) do
if (isSouthDivision) then
outputChatBox(factionRankTitle .. " " .. username .. " arrested " .. targetPlayerNick .. " for " .. jailtime .. " minute(s). (South Division)", value, 0, 102, 255)
outputChatBox("Crimes Committed: " .. reason .. ".", value, 0, 102, 255)
else
outputChatBox(factionRankTitle .. " " .. username .. " arrested " .. targetPlayerNick .. " for " .. jailtime .. " minute(s).", value, 0, 102, 255)
outputChatBox("Crimes Committed: " .. reason .. ".", value, 0, 102, 255)
end
end
exports.logs:logMessage("[PD/ARREST] ".. factionRankTitle .. " " .. username .. " jailed " .. targetPlayerNick .. " for " .. jailtime .. " minute(s). Reason: "..reason , 30)
end
end
end
end
end
end
end
addCommandHandler("arrest", arrestPlayer)
function timerPDUnjailPlayer(jailedPlayer)
if(isElement(jailedPlayer)) then
local timeServed = tonumber(getElementData(jailedPlayer, "pd.jailserved"))
local timeLeft = getElementData(jailedPlayer, "pd.jailtime")
local username = getPlayerName(jailedPlayer)
if ( timeServed ) then
exports['anticheat-system']:changeProtectedElementDataEx(jailedPlayer, "pd.jailserved", tonumber(timeServed)+1, false)
local timeLeft = timeLeft - 1
exports['anticheat-system']:changeProtectedElementDataEx(jailedPlayer, "pd.jailtime", timeLeft, false)
if (timeLeft<=0) then
theMagicTimer = nil
fadeCamera(jailedPlayer, false)
mysql:query_free("UPDATE characters SET pdjail_time='0', pdjail='0', pdjail_station='0' WHERE id=" .. mysql:escape_string(getElementData(jailedPlayer, "dbid")))
setElementDimension(jailedPlayer, getElementData(jailedPlayer, "pd.jailstation") <= 4 and 1 or 10583)
setElementInterior(jailedPlayer, 10)
setCameraInterior(jailedPlayer, 10)
setElementPosition(jailedPlayer, 241.3583984375, 115.232421875, 1003.2257080078)
setPedRotation(jailedPlayer, 270)
exports['anticheat-system']:changeProtectedElementDataEx(jailedPlayer, "pd.jailserved", 0, false)
exports['anticheat-system']:changeProtectedElementDataEx(jailedPlayer, "pd.jailtime", 0, false)
exports['anticheat-system']:changeProtectedElementDataEx(jailedPlayer, "pd.jailtimer")
exports['anticheat-system']:changeProtectedElementDataEx(jailedPlayer, "pd.jailstation")
toggleControl(jailedPlayer,'next_weapon',true)
toggleControl(jailedPlayer,'previous_weapon',true)
toggleControl(jailedPlayer,'fire',true)
toggleControl(jailedPlayer,'aim_weapon',true)
fadeCamera(jailedPlayer, true)
outputChatBox("Your time has been served.", jailedPlayer, 0, 255, 0)
elseif (timeLeft>0) then
mysql:query_free("UPDATE characters SET pdjail_time='" .. mysql:escape_string(timeLeft) .. "' WHERE id=" .. mysql:escape_string(getElementData(jailedPlayer, "dbid")))
local theTimer = setTimer(timerPDUnjailPlayer, 60000, 1, jailedPlayer)
exports['anticheat-system']:changeProtectedElementDataEx(jailedPlayer, "pd.jailtimer", theTimer, false)
outputDebugString("JAIL: " .. getPlayerName(jailedPlayer) .. " has ".. timeLeft .. " minutes left. New timer set.")
end
end
end
end
function showJailtime(thePlayer)
local ajailtime = getElementData(thePlayer, "jailtime")
if ajailtime then
outputChatBox("You have " .. ajailtime .. " minutes remaining on your admin jail.", thePlayer, 255, 194, 14)
else
local isJailed = getElementData(thePlayer, "pd.jailtimer")
if not (isJailed) then
outputChatBox("You are not jailed.", thePlayer, 255, 0, 0)
else
local jailtime = getElementData(thePlayer, "pd.jailtime")
outputChatBox("You have " .. jailtime .. " minutes remaining of your jail sentance.", thePlayer, 255, 194, 14)
end
end
end
addCommandHandler("jailtime", showJailtime)
function jailRelease(thePlayer, commandName, targetPlayerNick)
local logged = getElementData(thePlayer, "loggedin")
if (logged==1) then
local theTeam = getPlayerTeam(thePlayer)
local factionType = getElementData(theTeam, "type")
if factionType == 2 and isInArrestColshape(thePlayer) then
if not (targetPlayerNick) then
outputChatBox("SYNTAX: /release [Player Partial Nick / ID]", thePlayer, 255, 194, 14)
else
local targetPlayer, targetPlayerNick = exports.global:findPlayerByPartialNick(thePlayer, targetPlayerNick)
if targetPlayer then
local jailTimer = getElementData(targetPlayer, "pd.jailtimer")
local username = getPlayerName(thePlayer)
if (jailTimer) then
exports['anticheat-system']:changeProtectedElementDataEx(targetPlayer, "pd.jailtime", 1, false)
timerPDUnjailPlayer(targetPlayer)
exports.logs:logMessage("[PD/RELEASE]" .. username .. " released "..targetPlayerNick , 30)
else
outputChatBox("This player is not serving a jail sentance.", thePlayer, 255, 0, 0)
end
end
end
end
end
end
addCommandHandler("release", jailRelease)
[ Dodano : 2012-04-01, 14:41 ]
Skrypt zrobi? mi kolega ze stan?w z kt?rym nie mam ju? kontaktu i niestety nie wiem jak go naprawi? , pono? dzia?a dobrze ale komenda /arrest nie reaguje dla policjanta(to co da?em to wersja server)
Wysłany: 2012-04-01, 16:52
Piorun
Wiek: 32 Na forum: 6712 dni Posty: 1837
Nick w MP: Piorun
Piwa : 516
Podpi?te to jest pod mysql?
Wysłany: 2012-04-01, 18:27
Bogdan121
Wiek: 39 Na forum: 5184 dni Posty: 41
Tak raczej tak , upewnie sie czekaj , a wymaga tego?
[ Dodano : 2012-04-01, 18:30 ]
Nie jest podpi?te raczej , to co wstawi?em tu to ca?y kod skryptu , nic wi?cej nie ma.
Wysłany: 2012-04-01, 18:44
luki123luki123
Place Game
Wiek: 28 Na forum: 5275 dni Posty: 1948
Nick w MP: LuKiO
Piwa : 6101
Ej to jest serwer a mi sie wydaje ?e jeszcze musi by? clinet
Wysłany: 2012-04-01, 18:48
Bogdan121
Wiek: 39 Na forum: 5184 dni Posty: 41
Wysłany: 2012-04-01, 19:15
Piorun
Wiek: 32 Na forum: 6712 dni Posty: 1837
Nick w MP: Piorun
Piwa : 516
Czyli w zasadzie temat mo?na zamkn??. Poczytaj co nieco o MySQL (np. w tym dziale - znajd? poradnik), a potem postaraj si? podpi?? skrypt pod baz? danych. Btw. to na 100% nie jest strona 'client', bo wszystkie operacje na mysql wykonywane s? po stronie 'server'. Gdyby?my mieli tutaj dodane jakie? okienka GUI, albo ewidentnie w kodzie mo?na by dostrzec funkcj? 'triggerClientEvent...' to mo?na pokusi? si? o stwierdzenie, ?e brakuje w?a?nie strony klienta, lecz na szcz??cie tak nie jest.
Wysłany: 2012-04-01, 19:18
Bogdan121
Wiek: 39 Na forum: 5184 dni Posty: 41
Czyli o co w ko?cu chodzi ?eby to zadzia?a?o ?
[ Dodano : 2012-04-01, 19:25 ]
A wystarczy ze dodam
mysql = exports.mysql
na pocz?tku pliku?
Wysłany: 2012-04-01, 22:18
Piorun
Wiek: 32 Na forum: 6712 dni Posty: 1837
Nick w MP: Piorun
Piwa : 516
Nie. Poczytaj lepiej co to jest mysql, a dopiero potem bierz si? za proste komendy typu pobieranie danych z bazy, tworzenie tabel itp. Musisz po pierwsze MIE? tak? baz? danych. Wszystko jest w tym poradniku.
Wysłany: 2012-04-03, 19:11
Kafka
Wiek: 27 Na forum: 5222 dni Posty: 3
Nick w MP: Kafka
Piwa : 6
To jest cz??? skryptu z Valhalli (a konkretnie modyfikacji VEDIC). Bez skryptu 'anti-cheat', 'mysql' oraz zapewne 'pool' nic nie zrobisz. Do tego dochodzi jeszcze baza danych..
Tagi: skrypt :: więzienia
Anonymous
Na forum: 245 dni
Posty: 1
Anonymous Koniecznie zajrzyj na: