Jump to content

[Question] Add a player to team


B!ERPuNK

Recommended Posts

Hello guys, i have a question.

I have two resources, for convenience, let's call them A and B. In resource A, i want to create two (and eventually more) teams. This is the script i've added in the server script of resource A:

function createTeams () 
    local teamCops = createTeam ("cops", 0, 0, 255) 
    local teamMedics = createTeam ("medics", 0, 255, 255) 
end 

Now, in resource B, i want to add a player to team cops when he does /cop in the chatbox and to team medics if he does /medic. I have added the following script to the server script of resource B:

function becomeCop (source) 
    setPlayerTeam (source, cops) 
    outputChatBox ("You are now a cop!", source) 
end 

The problem is, when i do /cop, it doesn't add my player to the team. However, the text does show up in the chatbox. So can anyone tell me what i have done wrong :P ?

Thanks ;).

Link to comment
function becomeCop (source) 
    setPlayerTeam (source, getTeamFromName("cops")) 
    outputChatBox ("You are now a cop!", source) 
end 

Thanks a lot, it work's now :).

I thought the name of the team was also the team object, but i was wrong xD.

But thanks again, now people can finally get a job with my resource, or at least, become a medic or cop :P.

Link to comment
function becomeCop (source) 
    setPlayerTeam (source, getTeamFromName("cops")) 
    outputChatBox ("You are now a cop!", source) 
end 

Thanks a lot, it work's now :).

I thought the name of the team was also the team object, but i was wrong xD.

But thanks again, now people can finally get a job with my resource, or at least, become a medic or cop :P.

You welcome :)

Link to comment

Oh, i have 1 more question:

What function can you use to change a players skin? I know setPedSkin but i read it was deprecated. And using spawnPlayer is also kinda annoying, because then i have to add the coordinates and that kind of things, and i have used the event onPlayerSpawn a couple of times in my scripts that wouldnt work appropriately anymore if i use it.

Link to comment
Oh, i have 1 more question:

What function can you use to change a players skin? I know setPedSkin but i read it was deprecated. And using spawnPlayer is also kinda annoying, because then i have to add the coordinates and that kind of things, and i have used the event onPlayerSpawn a couple of times in my scripts that wouldnt work appropriately anymore if i use it.

setElementModel(playerElement,skinID)?

Link to comment
Hello guys, i have a question.

I have two resources, for convenience, let's call them A and B. In resource A, i want to create two (and eventually more) teams. This is the script i've added in the server script of resource A:

function createTeams () 
    local teamCops = createTeam ("cops", 0, 0, 255) 
    local teamMedics = createTeam ("medics", 0, 255, 255) 
end 

Now, in resource B, i want to add a player to team cops when he does /cop in the chatbox and to team medics if he does /medic. I have added the following script to the server script of resource B:

function becomeCop (source) 
    setPlayerTeam (source, cops) 
    outputChatBox ("You are now a cop!", source) 
end 

The problem is, when i do /cop, it doesn't add my player to the team. However, the text does show up in the chatbox. So can anyone tell me what i have done wrong :P ?

Thanks ;).

Btw, you made your team vars local, so you can't access them from other function.

Also, you have var "teamCop", why you using var called "cops" in there: setPlayerTeam (source, cops) ?

Link to comment

@CrazyDude:

read carefully if you are trying to help. you can mislead others.

I have two resources, for convenience, let's call them A and B.

(...)

In resource A (...) [1st script here]

(...)

Now, in resource B (...) [2nd script here]

You are suggesting that variables (even global) from one resource can be read in other resources.

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