NotAvailable Posted January 4, 2011 Posted January 4, 2011 Hi, im making an exp script, When you finish a race and u get the Hunter, The EXP script will trigger. But i get 4 errors: [10:24:40] WARNING: raceexp\Untitled 1.lua:9: Bad argument @ 'getPlayerAccount' [10:24:40] WARNING: raceexp\Untitled 1.lua:10: Bad argument @ 'getAccountData' [10:24:40] WARNING: raceexp\Untitled 1.lua:16: Bad argument @ 'setAccountData' I tried to fix it several times but it didnt work. heres the code(server): addEvent( "onPlayerWasted" ); addEventHandler( "onPlayerWasted", getRootElement(), function( killer ) if (killer) and (killer ~=source) then --EXP & RANK GEDOE-- local acc = getPlayerAccount(killer) local accountdata = getAccountData(acc,"exp") if accountdata then setAccountData(acc,"exp",tonumber(getAccountData(acc,"exp"))+1) setElementData(killer,"exp",tonumber(getAccountData(acc,"exp"))+1) outputChatBox("Total exp: ".. tonumber(getAccountData(acc,"exp"))+1,killer,0,255,0) else setAccountData(acc,"exp",1) end end end) Regards, Jesseunit
LuzC Posted January 4, 2011 Posted January 4, 2011 Show getPlayerAccount, setAccountData and setAccountData.
NotAvailable Posted January 4, 2011 Author Posted January 4, 2011 I know, There are some spaces between
Aibo Posted January 4, 2011 Posted January 4, 2011 https://wiki.multitheftauto.com/wiki/OnPlayerWasted first parameter of this event is ammo, not the killer.
NotAvailable Posted January 4, 2011 Author Posted January 4, 2011 Doesnt work. Im trying to make if someone gets the hunter he wins 3 exp But it doesnt work
Aibo Posted January 4, 2011 Posted January 4, 2011 why you're not using something like onVehicleEnter event then?
NotAvailable Posted January 4, 2011 Author Posted January 4, 2011 why you're not using something like onVehicleEnter event then? I tried that but it doesnt work.
NotAvailable Posted January 4, 2011 Author Posted January 4, 2011 heres my code: addEvent( "onPlayerWasted" ); addEventHandler( "onPlayerWasted", getRootElement(), function( ammo, attacker, weapon, bodypart ) if (attacker) and (attacker ~=source) then --EXP & RANK GEDOE-- local acc = getPlayerAccount(attacker) local accountdata = getAccountData(acc,"exp") if accountdata then setAccountData(acc,"exp",tonumber(getAccountData(acc,"exp"))+1) setElementData(attacker,"exp",tonumber(getAccountData(acc,"exp"))+1) outputChatBox("Total exp: ".. tonumber(getAccountData(acc,"exp"))+1,attacker,0,255,0) else setAccountData(acc,"exp",1) end end end)
NotAvailable Posted January 4, 2011 Author Posted January 4, 2011 why you're not using something like onVehicleEnter event then? Something like this? hunterVehicle = { [425]=true } function enterVehicle ( thePlayer, seat, jacked ) if ( hunterVehicle[getElementModel ( source )] ) then local acc = getPlayerAccount(attacker) local accountdata = getAccountData(acc,"exp") if accountdata then setAccountData(acc,"exp",tonumber(getAccountData(acc,"exp"))+10) setElementData(attacker,"exp",tonumber(getAccountData(acc,"exp"))+10) outputChatBox("Exp earned: ".. tonumber(getAccountData(acc,"exp"))+10,attacker,0,255,0) else setAccountData(acc,"exp",1) end end end addEventHandler ( "onVehicleEnter", getRootElement(), enterVehicle ) function doodVehicle ( thePlayer, seat, jacked ) if (thePlayer) and (thePlayer ~=source) then local acc = getPlayerAccount(attacker) local accountdata = getAccountData(acc,"exp") if accountdata then setAccountData(acc,"exp",tonumber(getAccountData(acc,"exp"))+1) setElementData(attacker,"exp",tonumber(getAccountData(acc,"exp"))+1) outputChatBox("Exp earned: ".. tonumber(getAccountData(acc,"exp"))+1,attacker,0,255,0) else setAccountData(acc,"exp",1) end end end addEventHandler ( "onPlayerWasted", getRootElement(), doodVehicle )
NotAvailable Posted January 5, 2011 Author Posted January 5, 2011 why you're not using something like onVehicleEnter event then? Something like this? hunterVehicle = { [425]=true } function enterVehicle ( thePlayer, seat, jacked ) if ( hunterVehicle[getElementModel ( source )] ) then local acc = getPlayerAccount(attacker) local accountdata = getAccountData(acc,"exp") if accountdata then setAccountData(acc,"exp",tonumber(getAccountData(acc,"exp"))+10) setElementData(attacker,"exp",tonumber(getAccountData(acc,"exp"))+10) outputChatBox("Exp earned: ".. tonumber(getAccountData(acc,"exp"))+10,attacker,0,255,0) else setAccountData(acc,"exp",1) end end end addEventHandler ( "onVehicleEnter", getRootElement(), enterVehicle ) function doodVehicle ( thePlayer, seat, jacked ) if (thePlayer) and (thePlayer ~=source) then local acc = getPlayerAccount(attacker) local accountdata = getAccountData(acc,"exp") if accountdata then setAccountData(acc,"exp",tonumber(getAccountData(acc,"exp"))+1) setElementData(attacker,"exp",tonumber(getAccountData(acc,"exp"))+1) outputChatBox("Exp earned: ".. tonumber(getAccountData(acc,"exp"))+1,attacker,0,255,0) else setAccountData(acc,"exp",1) end end end addEventHandler ( "onPlayerWasted", getRootElement(), doodVehicle ) Hmmm its still not working, it still says: bad argument at: setAccountData, getAccountData,setElementData
Aibo Posted January 5, 2011 Posted January 5, 2011 maybe change event arguments? like, you dont have «attacker» now
SDK Posted January 5, 2011 Posted January 5, 2011 Quick question, is it even possible to detect when a hunter shoots a vehicle? Afaik, it wasn't? And a small error: the outputChatBox's are wrong, you're adding exp after you already set the account data.
NotAvailable Posted January 5, 2011 Author Posted January 5, 2011 Its still not working i get this error: [15:30:13] WARNING: raceexp\Untitled 1.lua:5: Bad argument @ 'getElementType' This is the code(server): addEvent("onPlayerPickUpRacePickup", true) addEventHandler("onPlayerPickUpRacePickup", getRootElement(), function (guy, targetElem) local jij = getPlayerFromName(guy) if ( getElementType ( targetElem ) == "vehicle" ) and ( getElementModel ( targetElem ) == 425 ) then if (getPedOccupiedVehicle(jij)) then local acc = getPlayerAccount(jij) local accountdata = getAccountData(acc,"exp") if accountdata then setAccountData(acc,"exp",tonumber(getAccountData(acc,"exp"))+10) setElementData(jij,"exp",tonumber(getElementData(jij,"exp"))+10) outputChatBox("Exp earned: ".. tonumber(getAccountData(acc,"exp"))+10,jij,0,255,0) else setAccountData(acc,"exp",1) end end end end)
Castillo Posted January 5, 2011 Posted January 5, 2011 try this, addEventHandler("onPlayerPickUpRacePickup",getRootElement(), function (pickupID, pickupType, vehicleModel) if pickupType == "vehiclechange" then if vehicleModel == 425 then local acc = getPlayerAccount(source) local accountdata = getAccountData(acc,"exp") if accountdata then setAccountData(acc,"exp",tonumber(getAccountData(acc,"exp"))+10) setElementData(source,"exp",tonumber(getElementData(source,"exp"))+10) outputChatBox("Exp earned: ".. tonumber(getAccountData(acc,"exp"))+10,source,0,255,0) else setAccountData(acc,"exp",1) setElementData(source,"exp",tonumber(getElementData(source,"exp"))+10) outputChatBox("Exp earned: ".. tonumber(getAccountData(acc,"exp"))+10,source,0,255,0) end end end end)
Aibo Posted January 5, 2011 Posted January 5, 2011 because you've messed it up again. (what name? what guy?): https://wiki.multitheftauto.com/wiki/Resource:Race addEvent("onPlayerPickUpRacePickup", true) addEventHandler("onPlayerPickUpRacePickup", getRootElement(), function (pickupID, pickupType, vehicleID) -- and «source» is the player here if (vehicleID) and (vehicleID == 425) then -- since vehicleID is only passed with vehiclechange pickup type local acc = getPlayerAccount(source) local accountdata = tonumber(getAccountData(acc, "exp")) if not accountdata then accountdata = 0 -- set 0 exp if player has no exp in account data yet end accountdata = accountdata+10 -- increase exp, cause he picked up hunter setAccountData(acc, "exp", accountdata) setElementData(source, "exp", accountdata) outputChatBox("Exp earned: 10, total Exp: ".. accountdata, source, 0, 255, 0) end end) oops, too late
Castillo Posted January 5, 2011 Posted January 5, 2011 lol aiboforcen, his code didn't make any sense for 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