Jump to content

[HELP]Exp on hunter pickup


Recommended Posts

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

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
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
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

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

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

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 :D

Link to comment

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...