Jump to content

Bad argument @ getPlayerTeam


Recommended Posts

Can someone tell me why I get the error of 'Bad argument @ getPlayerTeam line 5 & 10?

Team = createTeam("Medics", 0, 255, 0) 
  
function createAmb(source) 
    getcteam = getTeamFromName ( "Medics" ) 
    getpteam = getPlayerTeam(source) 
    if (getpteam == getcteam) then 
        outputChatBox ("Sorry, but you are already employed as a medic!", source) 
    else 
        createVehicle (416, 1191.3876953125, -1325.90234375, 13.3984375) 
        setPlayerTeam(source, team) 
        outputChatBox ("You are now employed as a Medic, enter an ambulance to start your job!", source) 
    end 
end 
addEvent("ambul", true) 
addEventHandler("ambul", root, createAmb) 

Thanks

Link to comment
I believe it's because the source is the function that called the event, not the player. You must pass the correct parameters (the player) to the function and then use them.

So I've tried different parameters but all with the same result!

Try this

local Team = createTeam("Medics", 0, 255, 0) 
  
function createAmb() 
    local getpteam = getPlayerTeam(client) 
    if (getpteam == Team) then 
        outputChatBox ("Sorry, but you are already employed as a medic!", client) 
    else 
        createVehicle (416, 1191.3876953125, -1325.90234375, 13.3984375) 
        setPlayerTeam(client, team) 
        outputChatBox ("You are now employed as a Medic, enter an ambulance to start your job!", client,0,255,0) 
    end 
end 
addEvent("ambul", true) 
addEventHandler("ambul", root, createAmb) 

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