NotAvailable Posted January 4, 2011 Share 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 Link to comment
LuzC Posted January 4, 2011 Share Posted January 4, 2011 Show getPlayerAccount, setAccountData and setAccountData. Link to comment
NotAvailable Posted January 4, 2011 Author Share Posted January 4, 2011 I know, There are some spaces between Link to comment
Aibo Posted January 4, 2011 Share Posted January 4, 2011 https://wiki.multitheftauto.com/wiki/OnPlayerWasted first parameter of this event is ammo, not the killer. Link to comment
NotAvailable Posted January 4, 2011 Author Share Posted January 4, 2011 Doesnt work. Im trying to make if someone gets the hunter he wins 3 exp But it doesnt work Link to comment
Aibo Posted January 4, 2011 Share Posted January 4, 2011 why you're not using something like onVehicleEnter event then? Link to comment
NotAvailable Posted January 4, 2011 Author Share Posted January 4, 2011 why you're not using something like onVehicleEnter event then? I tried that but it doesnt work. Link to comment
NotAvailable Posted January 4, 2011 Author Share 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) Link to comment
NotAvailable Posted January 4, 2011 Author Share 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 ) Link to comment
NotAvailable Posted January 5, 2011 Author Share 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 Link to comment
Aibo Posted January 5, 2011 Share Posted January 5, 2011 maybe change event arguments? like, you dont have «attacker» now Link to comment
SDK Posted January 5, 2011 Share 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. Link to comment
NotAvailable Posted January 5, 2011 Author Share 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) Link to comment
Castillo Posted January 5, 2011 Share 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) Link to comment
Aibo Posted January 5, 2011 Share 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 Link to comment
Castillo Posted January 5, 2011 Share Posted January 5, 2011 lol aiboforcen, his code didn't make any sense for me. 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