diegofkda Posted May 22, 2011 Posted May 22, 2011 (edited) function onPlayerLogout ( ) local vehicle = getPedOccupiedVehicle ( source ) local playeraccount = getPlayerAccount ( source ) if ( playeraccount ) then setAccountData ( playeraccount, "s.handCar", getElementModel ( vehicle ) ) setAccountData ( playeraccount, "s.skin", tostring (getPedSkin (source))) setAccountData ( playeraccount, "s.HandMoney", getPlayerMoney ( source ) ) setAccountData (playeraccount, "s.upgradeWheel", getVehicleUpgradeOnSlot ( vehicle, 12 )) end end addEventHandler ( "onPlayerLogout", getRootElement ( ), onPlayerLogout ) The problem is the getPedOccupiedVehicle, debugscript says bad argument getElementModel. getAccountData gets correctly the handmoney and skin, but doesn't get the upgradewheel and handcar, because can't read getPedOccupiedVehicle, why not? Edited May 22, 2011 by Guest
TEDERIs Posted May 22, 2011 Posted May 22, 2011 Try adding a check. For example: function onPlayerLogout ( ) local vehicle = getPedOccupiedVehicle ( source ) if vehicle then --code end end addEventHandler ( "onPlayerLogout", getRootElement ( ), onPlayerLogout ) OR function onPlayerLogout ( ) if isPedInVehicle(source) then local vehicle = getPedOccupiedVehicle ( source ) --code end end addEventHandler ( "onPlayerLogout", getRootElement ( ), onPlayerLogout )
diegofkda Posted May 22, 2011 Author Posted May 22, 2011 Keeps not working, the problem is, the server can't get the actual ped vehicle, I want to get the ID and save it on the player account, and this says "Bad Argument getElementModel"... can someone help??
diegofkda Posted May 22, 2011 Author Posted May 22, 2011 I know, but I'm on a vehicle and it says bad arguments.
Kenix Posted May 22, 2011 Posted May 22, 2011 try this function onPlayerLogout ( ) local isVeh = isPedInVehicle(source) if isVeh then local vehicle = getPedOccupiedVehicle ( source ) local playeraccount = getPlayerAccount ( source ) if ( vehicle ) and ( playeraccount ) then local model = getElementModel ( vehicle ) local skin = getPedSkin (source) local money = getPlayerMoney ( source ) local vehUpgrade = getVehicleUpgradeOnSlot ( vehicle, 12 ) setAccountData ( playeraccount, "s.handCar", model ) setAccountData ( playeraccount, "s.skin", skin ) setAccountData ( playeraccount, "s.HandMoney", money ) setAccountData (playeraccount, "s.upgradeWheel", vehUpgrade ) end end end addEventHandler ( "onPlayerLogout", getRootElement ( ), onPlayerLogout )
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