ahmedo01 Posted July 24, 2014 Share Posted July 24, 2014 function onPlayerQuit ( ) -- when a player leaves, store his current money amount in his account data local playeraccount = getPlayerAccount ( source ) if ( playeraccount ) and not isGuestAccount ( playeraccount ) then -- if the player is logged in local playermoney = getPlayerMoney ( source ) -- get the player money local playerteam = getPlayerTeam ( source ) local playerskin = getPedSkin ( source ) local playerwanted = getPlayerWantedLevel ( source ) local playeroccupation = getElementData ( source, "occupation") local x,y,z = getElementPosition ( source ) setAccountData ( playeraccount, "cg.money", playermoney ) -- save it in his account setAccountData ( playeraccount, "cg.team", playerteam ) setAccountData ( playeraccount, "cg.skin", playerskin ) setAccountData ( playeraccount, "cg.wanted", playerwanted ) setAccountData ( playeraccount, "cg.occupation", playeroccupation ) setAccountData ( playeraccount, "cg.location", x,y,z ) end end function onPlayerLogin (_, playeraccount ) -- when a player logins, retrieve his money amount from his account data and set it if ( playeraccount ) then local playermoney = getAccountData ( playeraccount, "cg.money" ) local playerteam = getAccountData ( playeraccount, "cg.team" ) local playerskin = getAccountData ( playeraccount, "cg.skin" ) local playerwanted = getAccountData ( playeraccount, "cg.wanted" ) local playeroccupation = getAccountData ( playeraccount, "cg.occupation" ) local x,y,z = getAccountData ( playeraccount, "cg.location" ) -- make sure there was actually a value saved under this key (check if playermoney is not false). -- this will for example not be the case when a player plays the gametype for the first time if ( playermoney ) then setPlayerMoney ( source, playermoney ) outputChatBox ( playermoney, getRootElement()) end if ( playerteam ) then setPlayerTeam ( source, playerteam ) outputChatBox ( playerteam , getRootElement()) end if ( playerskin ) then setElementModel ( source, playerskin ) outputChatBox ( playerskin , getRootElement()) end if ( playerwanted ) then setPlayerWantedLevel ( source, playerwanted ) outputChatBox ( playerwanted , getRootElement()) end if ( playeroccupation ) then setElementData ( source, "occupation", playeroccupation) outputChatBox ( playeroccupation ,getRootElement()) end if ( x,y,z ) then setElementPosition ( source, x, y, z) outputChatBox ( x,y,z ,getRootElement()) end end end addEventHandler ( "onPlayerQuit", getRootElement ( ), onPlayerQuit ) addEventHandler ( "onPlayerLogin", getRootElement ( ), onPlayerLogin ) i make this system. but it is not working. no errors no warnings. Link to comment
ViRuZGamiing Posted July 24, 2014 Share Posted July 24, 2014 Use [LUA] tags and try /debugscript 3 ingame (need to be logged in as admin), then post debug here Link to comment
Moderators IIYAMA Posted July 24, 2014 Moderators Share Posted July 24, 2014 line 16 incorrect. setAccountData ( playeraccount, "cg.location", x,y,z ) setAccountData ( playeraccount, "cg.location", x .. "," .. y .. "," .. z ) local contentTable = split(content, string.byte('/')) line 28 incorrect. local x,y,z = getAccountData ( playeraccount, "cg.location" ) local xyz = getAccountData ( playeraccount, "cg.location" ) if xyz then xyz = split(xyz, string.byte(",")) end line 51 incorrect. if ( x,y,z ) then if xyz then Line 52 incorrect. setElementPosition ( source, x, y, z) setElementPosition ( source, xyz[1], xyz[2], xyz[3]) Line 53 incorrect. outputChatBox ( x,y,z ,getRootElement()) outputChatBox ( tostring(xyz[1]) .. tostring(xyz[2]) .. tostring(xyz[3]) ,getRootElement()) Use your debugscript fool, all errors are visible. Link to comment
ahmedo01 Posted July 24, 2014 Author Share Posted July 24, 2014 okey thanks. new code function onPlayerQuit ( ) -- when a player leaves, store his current money amount in his account data local playeraccount = getPlayerAccount ( source ) if ( playeraccount ) and not isGuestAccount ( playeraccount ) then -- if the player is logged in local playermoney = getPlayerMoney ( source ) -- get the player money local playerteam = getPlayerTeam ( source ) local playerskin = getPedSkin ( source ) local playerwanted = getPlayerWantedLevel ( source ) local playeroccupation = getElementData ( source, "occupation") local x,y,z = getElementPosition ( source ) setAccountData ( playeraccount, "cg.money", playermoney ) -- save it in his account setAccountData ( playeraccount, "cg.team", playerteam ) setAccountData ( playeraccount, "cg.skin", playerskin ) setAccountData ( playeraccount, "cg.wanted", playerwanted ) setAccountData ( playeraccount, "cg.occupation", playeroccupation ) setAccountData ( playeraccount, "cg.location", x .. "," .. y .. "," .. z ) end end function onPlayerLogin (_, playeraccount ) -- when a player logins, retrieve his money amount from his account data and set it if ( playeraccount ) then local playermoney = getAccountData ( playeraccount, "cg.money" ) local playerteam = getAccountData ( playeraccount, "cg.team" ) local playerskin = getAccountData ( playeraccount, "cg.skin" ) local playerwanted = getAccountData ( playeraccount, "cg.wanted" ) local playeroccupation = getAccountData ( playeraccount, "cg.occupation" ) local xyz = getAccountData ( playeraccount, "cg.location" ) if xyz then xyz = split(xyz, string.byte(",")) end -- make sure there was actually a value saved under this key (check if playermoney is not false). -- this will for example not be the case when a player plays the gametype for the first time if ( playermoney ) then setPlayerMoney ( source, playermoney ) outputChatBox ( playermoney, getRootElement()) end if ( playerteam ) then setPlayerTeam ( source, playerteam ) outputChatBox ( playerteam , getRootElement()) end if ( playerskin ) then setElementModel ( source, playerskin ) outputChatBox ( playerskin , getRootElement()) end if ( playerwanted ) then setPlayerWantedLevel ( source, playerwanted ) outputChatBox ( playerwanted , getRootElement()) end if ( playeroccupation ) then setElementData ( source, "occupation", playeroccupation) outputChatBox ( playeroccupation ,getRootElement()) end if xyz then spawnPlayer ( source, xyz[1], xyz[2], xyz[3] ) outputChatBox ( tostring(xyz[1]) .. tostring(xyz[2]) .. tostring(xyz[3]) ,getRootElement()) end end end addEventHandler ( "onPlayerQuit", getRootElement ( ), onPlayerQuit ) addEventHandler ( "onPlayerLogin", getRootElement ( ), onPlayerLogin ) but this script not save team, occupation, skin and i have small question local normalvehicle = { [1] = {713,-528,16,"checkpoint",2.0,1,1,1,255}, } normalvehiclemarkers = createMarker(normalvehicle) function success() outputChatBox("Success") end addEventHandler ( "onResourceStart", getRootElement(), success ) this basic code. i want to vehicle markers in tabla but give warning expected vector3 at argument 1 line 4 Link to comment
Moderators IIYAMA Posted July 24, 2014 Moderators Share Posted July 24, 2014 function onPlayerQuit ( ) -- when a player leaves, store his current money amount in his account data local playeraccount = getPlayerAccount ( source ) if ( playeraccount ) and not isGuestAccount ( playeraccount ) then -- if the player is logged in local playermoney = getPlayerMoney ( source ) -- get the player money local playerteam = getPlayerTeam ( source ) local playerskin = getPedSkin ( source ) local playerwanted = getPlayerWantedLevel ( source ) local playeroccupation = getElementData ( source, "occupation") local x,y,z = getElementPosition ( source ) setAccountData ( playeraccount, "cg.money", playermoney ) -- save it in his account if playerteam then setAccountData ( playeraccount, "cg.team", getTeamName(playerteam) ) end setAccountData ( playeraccount, "cg.skin", playerskin ) setAccountData ( playeraccount, "cg.wanted", playerwanted ) if playeroccupation then setAccountData ( playeraccount, "cg.occupation", tostring(playeroccupation)) end setAccountData ( playeraccount, "cg.location", x .. "," .. y .. "," .. z ) end end function onPlayerLogin (_, playeraccount ) -- when a player logins, retrieve his money amount from his account data and set it if ( playeraccount ) then local playermoney = tonumber(getAccountData ( playeraccount, "cg.money" )) local playerTeamName = getAccountData ( playeraccount, "cg.team" ) local playerskin = tonumber(getAccountData ( playeraccount, "cg.skin" )) local playerwanted = tonumber(getAccountData ( playeraccount, "cg.wanted" )) local playeroccupation = getAccountData ( playeraccount, "cg.occupation" ) local xyz = getAccountData ( playeraccount, "cg.location" ) if xyz then xyz = split(xyz, string.byte(",")) end -- make sure there was actually a value saved under this key (check if playermoney is not false). -- this will for example not be the case when a player plays the gametype for the first time if ( playermoney ) then setPlayerMoney ( source, playermoney ) outputChatBox ( playermoney, getRootElement()) end if ( playerTeamName ) then local playerteam = getTeamFromName(playerteam) if playerteam then setPlayerTeam ( source, playerteam ) --outputChatBox ( playerteam , getRootElement()) end end if ( playerskin ) then setElementModel ( source, playerskin ) --outputChatBox ( playerskin , getRootElement()) end if ( playerwanted ) then setPlayerWantedLevel ( source, playerwanted ) outputChatBox ( playerwanted , getRootElement()) end if ( playeroccupation ) then local vehicles = getElementsByType("vehicle") local vehicle for i=1,#vehicles do if tostring(vehicles[i]) == playeroccupation then vehicle = vehicles[i] break end end if vehicle then setElementData ( source, "occupation", vehicle) else setAccountData ( playeraccount, "cg.occupation",false) end --outputChatBox ( playeroccupation ,getRootElement()) end if xyz then spawnPlayer ( source, xyz[1], xyz[2], xyz[3] ) outputChatBox ( tostring(xyz[1]) .. tostring(xyz[2]) .. tostring(xyz[3]) ,getRootElement()) end end end addEventHandler ( "onPlayerQuit", getRootElement ( ), onPlayerQuit ) addEventHandler ( "onPlayerLogin", getRootElement ( ), onPlayerLogin ) local normalvehicle = { [1] = {713,-528,16,"checkpoint",2.0,1,1,1,255}, } normalvehiclemarkers = createMarker(unpack(normalvehicle[math.random(#normalvehicle)])) Link to comment
ahmedo01 Posted July 24, 2014 Author Share Posted July 24, 2014 saves skin position and money but not save occupation, team. 2. script thank for unpack but this car spawners can i dont use math.random? i want all markers? my last question this i have this map: <map edf:definitions="editor_main"> <marker id="lspdmarker" type="cylinder" color="#0000ffff" size="1" interior="0" dimension="0" alpha="255" posX="1554.7" posY="-1675.7" posZ="15.11605" rotX="0" rotY="0" rotZ="0"></marker> </map> i want to use lspdmarker in script why i can do? thank you very much Link to comment
Moderators IIYAMA Posted July 24, 2014 Moderators Share Posted July 24, 2014 local marker = getElementByID("lspdmarker") function onPlayerQuit ( ) -- when a player leaves, store his current money amount in his account data local playeraccount = getPlayerAccount ( source ) if ( playeraccount ) and not isGuestAccount ( playeraccount ) then -- if the player is logged in local playermoney = getPlayerMoney ( source ) -- get the player money local playerteam = getPlayerTeam ( source ) local playerskin = getPedSkin ( source ) local playerwanted = getPlayerWantedLevel ( source ) local playeroccupation = getElementData ( source, "occupation") local x,y,z = getElementPosition ( source ) setAccountData ( playeraccount, "cg.money", playermoney ) -- save it in his account if playerteam then setAccountData ( playeraccount, "cg.team", getTeamName(playerteam) ) end setAccountData ( playeraccount, "cg.skin", playerskin ) setAccountData ( playeraccount, "cg.wanted", playerwanted ) if playeroccupation then setAccountData ( playeraccount, "cg.occupation", tostring(playeroccupation)) end setAccountData ( playeraccount, "cg.location", x .. "," .. y .. "," .. z ) end end function onPlayerLogin (_, playeraccount ) -- when a player logins, retrieve his money amount from his account data and set it if ( playeraccount ) then local playermoney = tonumber(getAccountData ( playeraccount, "cg.money" )) local playerTeamName = getAccountData ( playeraccount, "cg.team" ) local playerskin = tonumber(getAccountData ( playeraccount, "cg.skin" )) local playerwanted = tonumber(getAccountData ( playeraccount, "cg.wanted" )) local playeroccupation = getAccountData ( playeraccount, "cg.occupation" ) local xyz = getAccountData ( playeraccount, "cg.location" ) if xyz then xyz = split(xyz, string.byte(",")) end -- make sure there was actually a value saved under this key (check if playermoney is not false). -- this will for example not be the case when a player plays the gametype for the first time if ( playermoney ) then setPlayerMoney ( source, playermoney ) outputChatBox ( playermoney, getRootElement()) end if ( playerTeamName ) then local playerteam = getTeamFromName(playerTeamName) if playerteam then setPlayerTeam ( source, playerteam ) --outputChatBox ( playerteam , getRootElement()) end end if ( playerskin ) then setElementModel ( source, playerskin ) --outputChatBox ( playerskin , getRootElement()) end if ( playerwanted ) then setPlayerWantedLevel ( source, playerwanted ) outputChatBox ( playerwanted , getRootElement()) end if ( playeroccupation ) then local vehicles = getElementsByType("vehicle") local vehicle for i=1,#vehicles do if tostring(vehicles[i]) == playeroccupation then vehicle = vehicles[i] break end end if vehicle then setElementData ( source, "occupation", vehicle) else setAccountData ( playeraccount, "cg.occupation",false) end --outputChatBox ( playeroccupation ,getRootElement()) end if xyz then spawnPlayer ( source, xyz[1], xyz[2], xyz[3] ) outputChatBox ( tostring(xyz[1]) .. tostring(xyz[2]) .. tostring(xyz[3]) ,getRootElement()) end end end addEventHandler ( "onPlayerQuit", getRootElement ( ), onPlayerQuit ) addEventHandler ( "onPlayerLogin", getRootElement ( ), onPlayerLogin ) Team fixed/ saved using it's name. The vehicle is saved using it's userdata. After refreshing the vehicles they will be gone. If you want to save vehicles, you must save everything of them. Position/rotation/mode/etc. Link to comment
ahmedo01 Posted July 24, 2014 Author Share Posted July 24, 2014 Occupation not vehicle. For ex. FBI SWAT. Link to comment
Moderators IIYAMA Posted July 24, 2014 Moderators Share Posted July 24, 2014 function onPlayerQuit ( ) -- when a player leaves, store his current money amount in his account data local playeraccount = getPlayerAccount ( source ) if ( playeraccount ) and not isGuestAccount ( playeraccount ) then -- if the player is logged in local playermoney = getPlayerMoney ( source ) -- get the player money local playerteam = getPlayerTeam ( source ) local playerskin = getPedSkin ( source ) local playerwanted = getPlayerWantedLevel ( source ) local playeroccupation = getElementData ( source, "occupation") local x,y,z = getElementPosition ( source ) setAccountData ( playeraccount, "cg.money", playermoney ) -- save it in his account if playerteam then setAccountData ( playeraccount, "cg.team", getTeamName(playerteam) ) end setAccountData ( playeraccount, "cg.skin", playerskin ) setAccountData ( playeraccount, "cg.wanted", playerwanted ) if playeroccupation then setAccountData ( playeraccount, "cg.occupation", tostring(playeroccupation)) end setAccountData ( playeraccount, "cg.location", x .. "," .. y .. "," .. z ) end end function onPlayerLogin (_, playeraccount ) -- when a player logins, retrieve his money amount from his account data and set it if ( playeraccount ) then local playermoney = tonumber(getAccountData ( playeraccount, "cg.money" )) local playerTeamName = getAccountData ( playeraccount, "cg.team" ) local playerskin = tonumber(getAccountData ( playeraccount, "cg.skin" )) local playerwanted = tonumber(getAccountData ( playeraccount, "cg.wanted" )) local playeroccupation = getAccountData ( playeraccount, "cg.occupation" ) local xyz = getAccountData ( playeraccount, "cg.location" ) if xyz then xyz = split(xyz, string.byte(",")) end -- make sure there was actually a value saved under this key (check if playermoney is not false). -- this will for example not be the case when a player plays the gametype for the first time if ( playermoney ) then setPlayerMoney ( source, playermoney ) outputChatBox ( playermoney, getRootElement()) end if ( playerTeamName ) then local playerteam = getTeamFromName(playerTeamName) if playerteam then setPlayerTeam ( source, playerteam ) --outputChatBox ( playerteam , getRootElement()) end end if ( playerskin ) then setElementModel ( source, playerskin ) --outputChatBox ( playerskin , getRootElement()) end if ( playerwanted ) then setPlayerWantedLevel ( source, playerwanted ) outputChatBox ( playerwanted , getRootElement()) end if ( playeroccupation ) then setElementData ( source, "occupation", tostring(playeroccupation)) --outputChatBox ( playeroccupation ,getRootElement()) end if xyz then spawnPlayer ( source, xyz[1], xyz[2], xyz[3] ) outputChatBox ( tostring(xyz[1]) .. tostring(xyz[2]) .. tostring(xyz[3]) ,getRootElement()) end end end addEventHandler ( "onPlayerQuit", getRootElement ( ), onPlayerQuit ) addEventHandler ( "onPlayerLogin", getRootElement ( ), onPlayerLogin ) ah, then I set it back. Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now