Wysłany: 2014-05-07, 20:49
Zgredek666
LUA
Wiek: 27 Na forum: 4722 dni Posty: 251
Nick w MP: Zgredek
Piwa : 442
Witam! Mam problem ot?? nie zapisuje mi paszportu po wyj?ciu gracza z serwera. Bardzo prosz? o pomoc. Oczywi?cie daj? zimne function GivePassport ( player , commandName , nick )
local targetPlayer = getPlayerFromName ( tostring ( nick ))
local team = getTeamFromName ( "Urz?d" )
if getPlayerTeam ( player ) == team then
if targetPlayer == false then
outputChatBox ( "Gracz nie jest podloczony do serwera" , player )
return
end
setElementData ( targetPlayer , "prawoa" , true )
outputChatBox ( "Gracz " .. nick .. " otrzyma? Paszport" , player )
else
outputChatBox ( "Nie jestes pracownikiem urz?du!" , player )
local player = getPlayerAccount ( player )
if player then
if not isGuestAccount ( player ) then
local nick = getAccountData ( player , "prawoa" ) or 0
if nick then
setElementData ( targetPlayer , "prawoa" , tonumber ( nick ))
end
end
end
end
local player = getPlayerAccount ( player )
if player then
if not isGuestAccount ( player ) then
local nick = getElementData ( player , "prawoa" ) or 0
if nick then
setAccountData ( player , "prawoa" , nick )
end
end
end
end
addEventHandler ( "onPlayerQuit" , getRootElement (), GivePassport )
addEventHandler ( "onPlayerLogin" , getRootElement (), GivePassport )
function CheckPassport ( player , commandName , nick )
local targetPlayer = getPlayerFromName ( tostring ( nick ))
local team = getTeamFromName ( "Stra? Graniczna" )
if getPlayerTeam ( player ) == team then
if targetPlayer == false then
outputChatBox ( "Gracz nie jest podlonczony do serwera" , player )
return
end
if getElementData ( targetPlayer , "prawoa" ) then
outputChatBox ( "Gracz posiada Paszport" , player )
else
outputChatBox ( "Gracz nie posiada Paszportu" , player )
end
else
outputChatBox ( "Nie jestes funkcjonariuszem SG!" , player )
end
end
function TakePassport ( player , commandName , nick )
local targetPlayer = getPlayerFromName ( tostring ( nick ))
local team = getTeamFromName ( "Stra? Graniczna" )
if getPlayerTeam ( player ) == team then
if targetPlayer == false then
outputChatBox ( "Gracz nie jest podloczony do serwera" , player )
return
end
setElementData ( targetPlayer , "prawoa" , false )
outputChatBox ( "Gracz " .. nick .. " zosta? pozbawiony paszportu" , player )
else
outputChatBox ( "Nie jestes funkcjonariuszem SG!" , player )
end
end
addCommandHandler ( "dajpaszport" , GivePassport )
addCommandHandler ( "zobaczpaszport" , CheckPassport )
addCommandHandler ( "zabierzpaszport" , TakePassport )
Wysłany: 2014-05-07, 21:21
Artysta
Lua, Lua, Czekolada
Wiek: 28 Na forum: 4466 dni Posty: 240
Nick w MP: Artysta/Koojot
Piwa : 1427
A nie lepiej zrobi? na setAccountData ?
Podpis
Something is coming..
Wysłany: 2014-05-08, 16:21
Zgredek666
LUA
Wiek: 27 Na forum: 4722 dni Posty: 251
Nick w MP: Zgredek
Piwa : 442
function GivePassport ( player , commandName , nick , gracz )
local targetPlayer = getPlayerFromName ( tostring ( nick ))
local team = getTeamFromName ( "Urz?d" )
if getPlayerTeam ( player ) == team then
if targetPlayer == false then
outputChatBox ( "Gracz nie jest podloczony do serwera" , player )
return
end
setElementData ( targetPlayer , "prawoa" , true )
outputChatBox ( "Gracz " .. nick .. " otrzyma? Paszport" , player )
else
outputChatBox ( "Nie jestes pracownikiem urz?du!" , player )
end
local gracz = getPlayerAccount ( targetPlayer )
if ( gracz ) and not isGuestAccount ( gracz ) then -- if the player is logged in
setAccountData ( gracz , "prawoa" , gracz ) -- save it in his account
end
end
function onPlayerLogin ( targetPlayer , gracz , prawoa )
local gracz = getPlayerAccount ( targetPlayer )
if ( gracz ) then
local prawoa = getAccountData ( gracz , "prawoa" )
if ( prawoa ) then
getAccountData ( gracz , "prawoa" , prawoa )
end
end
end
addEventHandler ( "onPlayerQuit" , getRootElement ( ), GivePassport )
addEventHandler ( "onPlayerLogin" , getRootElement ( ), onPlayerLogin ) Stworzy?em co? takiego ale nie dzia?a. Nie ma te? b??d?w w debugu
Wysłany: 2014-05-08, 20:59
maciek3286
LUA Developer
Wiek: 26 Na forum: 5201 dni Posty: 230
Nick w MP: maciek00
Piwa : 3207
niedziwie sie ze sie nie zapisuje bo niby gdzie to by sie mialo zapisac. Proponuje zrobi? to w SQL Lite lub setAccountData.
Podpis
"Ludzie będą zawsze dla ciebie źli, jeżeli konieczność nie zmusi ich do tego, by byli dobrzy" ~~ Niccolò Machiavelli
Wysłany: 2014-05-16, 13:38
Rebeka
Szefostwo
Wiek: 31 Na forum: 4452 dni Posty: 37
Nick w MP: Projekt
Piwa : 15
tutaj daje gotowy skrypt urzad daje a policja sprawdza
Kod: function GivePassportb ( player, commandName, nick )
if ( not nick ) then return end
local targetPlayer = getPlayerFromName( nick )
local team = getTeamFromName ( "Urzad" )
if ( getPlayerTeam ( player ) == team ) then
if ( not targetPlayer ) then
outputChatBox("Gracz nie jest pod??czony do serwera", player)
return
end
setElementData ( targetPlayer, "paszport", true )
outputChatBox ( "Gracz " .. nick .. " otrzyma? paszport.", player )
else
outputChatBox("Nie jestes pracownikiem urzedu!", player)
end
end
addCommandHandler ( "wydajpaszport", GivePassportb )
function CheckPassportb ( player, commandName, nick )
if ( not nick ) then return end
local targetPlayer = getPlayerFromName ( nick )
local team = getTeamFromName ( "Policja" )
if getPlayerTeam(player) == team then
if ( not targetPlayer ) then
outputChatBox("Gracz nie jest pod??czony do serwera", player)
return
end
local paszport = getElementData ( targetPlayer, "paszport" ) and "Gracz Posiada paszport ." or "Gracz nie posiada paszportu."
outputChatBox ( paszport, player )
else
outputChatBox("Nie jestes pracownikiem Policji!", player)
end
end
addCommandHandler ( "zobaczpaszport", CheckPassportb )
addEventHandler ( "onPlayerLogin", root,
function ( _, account )
local paszport = getAccountData ( account, "paszport" ) or false
setElementData ( source, "paszport", paszport )
end
)
addEventHandler ( "onPlayerLogout", root,
function ( account )
local paszport = getElementData ( source, "paszport" ) or false
setAccountData ( account, "paszport", paszport )
end
)
addEventHandler ( "onPlayerQuit", root,
function ( )
local account = getPlayerAccount ( source )
if ( not isGuestAccount ( account ) ) then
local paszport = getElementData ( source, "paszport" ) or false
setAccountData ( account, "paszport", paszport )
end
end
)
Tagi: paszport
Anonymous
Na forum: 245 dni
Posty: 1
Anonymous Koniecznie zajrzyj na: