27.11.2012, 20:40
In this tutorial, I will show you how to make a very basic command to join a team.
Firstly, We start by defining our teams. So before your OnGameModeInit add this.
And now defining our team colors, so;
Now we want to add a new Global Variable to store our teams, So again before OnGameModeInit add the following;
Now we want to add the command to join a team, So under OnPlayerCommandText, Paste this.
Now even though this code is pretty self explanatory, I will explain it for you.
Basically this will send whoever entered the command (playerid) Then send them the string "You are now on the cop team" In the color blue (Defined as copcolor).
Now this will set the player who executed the command into the cop team, Storing it in the variable pTeam.
Self explanatory, Sets the players skin to 281 (Easily changeable just choose a skin id from here and replace the 281 with your selected skin id.
Also self explanatory, Gives the player the selected gun and amount of ammo (Ids are in that order so replace 17 for your gun id and 10 for the amount of ammo) Gun ids can be found here
Once again, Self explanatory. 309 is your x co-ordinate, 2060 is your y co-ordinate and 18 is your z co-ordinate.
(You can get these by going in-game and typing /save at the co-ordinates location you want, Then going into your user files.
Note: I am not saying this is the best way to create teams in anyway. However this can be used as a learning base for new scripters. You can also improve this and maybe soon i will update this tutorial to add team cars using enums also.
Hope this tutorial has helped, Again if i have missed something out then please notify me so i can correct it.
Firstly, We start by defining our teams. So before your OnGameModeInit add this.
pawn Код:
#define team_cop 1 // Cop team
#define team_criminal 2 // Criminal team
pawn Код:
#define copcolor 0x375FFFFF
#define criminalcolor 0xFF0000FF
pawn Код:
new pTeam[MAX_PLAYERS];
pawn Код:
if (strcmp("/cop", cmdtext, true, 10) == 0)
{
SendClientMessage(playerid, soldiercolor, "You are now on the cop team");
pTeam[playerid] = team_cop;
SetPlayerSkin(playerid, 281);
GivePlayerWeapon(playerid, 17, 10);
SetPlayerPos(playerid, 309, 2060, 18);
return 1;
}
pawn Код:
SendClientMessage(playerid, copcolor, "You are now on the cop team");
pawn Код:
pTeam[playerid] = team_cop;
pawn Код:
SetPlayerSkin(playerid, 281);
pawn Код:
GivePlayerWeapon(playerid, 17, 10);
pawn Код:
SetPlayerPos(playerid, 309, 2060, 18);
(You can get these by going in-game and typing /save at the co-ordinates location you want, Then going into your user files.
Note: I am not saying this is the best way to create teams in anyway. However this can be used as a learning base for new scripters. You can also improve this and maybe soon i will update this tutorial to add team cars using enums also.
Hope this tutorial has helped, Again if i have missed something out then please notify me so i can correct it.