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 "Everything exists, because otherwise nothing would", Bob Marley, 2015.
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 ) This is my GitHub repository where you can find a lot of my work. And this is my YouTube channel with reviews of some resources. Good luck and enjoy MTA!
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?? "Everything exists, because otherwise nothing would", Bob Marley, 2015.
karlis Posted May 22, 2011 Posted May 22, 2011 bad arg is when ped is on foot. [WIP]GTA IV style hud+custom blips + blip text + circular radar areas
diegofkda Posted May 22, 2011 Author Posted May 22, 2011 I know, but I'm on a vehicle and it says bad arguments. "Everything exists, because otherwise nothing would", Bob Marley, 2015.
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 ) http://vk.com/the_kenix Вопросы задавайте на форуме, не пишите мне в личку. Please don't pm me.
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