Jump to content

[Question] Add a player to team


B!ERPuNK

Recommended Posts

Posted

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

signaturepp.png

Total freedom, no exceptions!

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

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

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

signaturepp.png

Total freedom, no exceptions!

Posted
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 :)

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Posted

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.

signaturepp.png

Total freedom, no exceptions!

Posted
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)?

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Posted
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) ?

Posted

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

Multi theft auto tools - replace cars and peds, move your map or compile your Lua files online!

programista php rzeszów

Need free webhosting for your small site? PM me. Need help with portforwarding? PM me. Do not PM me asking for help with scripting.

Having problems with port forwarding? Send me pm, I can do whole thing for you using TeamViewer (already helped about 20 people, no worries)!

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