How do I make a command that changes a player's team ?
#1

How do I make a command that changes a player's team ?
Reply
#2

What do you mean -.-
Reply
#3

What are your team variables? I will code you one.
Reply
#4

Code:
	    team[playerid] = 2;
        infected[playerid] = 0;
		SetPlayerPos(playerid,X,Y,Z);
		SetPlayerColor(playerid,ZRED);
		SetPlayerTeam(playerid, 2);
		SetPlayerHealth(playerid, 200);
 		SetPlayerSkin(playerid,162);
		GameTextForPlayer(playerid,"~r~Zombie: ~b~/hide",10000,1);
		return 1;
	}
	if(team[playerid] == 1) //Humans
	{
		SetPlayerColor(playerid,CYAN);
		SetPlayerTeam(playerid, 1);
		GameTextForPlayer(playerid,"~b~~h~Human: ~b~/panic",10000,1);
		GivePlayerWeapon(playerid,24,300);
 		SetPlayerSkin(playerid,188);
		GivePlayerWeapon(playerid,25,300);
		GivePlayerMoney(playerid, 20000);
	}
	if(team[playerid] == 2) //Zombies
	{
		SetPlayerColor(playerid,ZRED);
		SetPlayerTeam(playerid, 2);
		SetPlayerHealth(playerid, 200);
 		SetPlayerSkin(playerid,162);
		GameTextForPlayer(playerid,"~r~Zombie: ~b~/hide",10000,1);
	}
	if(team[playerid] == 4) //Scientists
	{
		SetPlayerColor(playerid,WHITE);
		SetPlayerTeam(playerid, 1);
		GameTextForPlayer(playerid,"~w~Scientist: ~b~/anti",10000,1);
		GivePlayerWeapon(playerid,23,300);
		SetPlayerSkin(playerid, 70);
		GivePlayerMoney(playerid, 20000);
		SetPlayerArmour(playerid, 100);
	}
	if(team[playerid] == 5) //Doctor
	{
		SetPlayerColor(playerid,ORANGE);
		SetPlayerTeam(playerid, 1);
		GameTextForPlayer(playerid,"~r~~h~Doctor: ~b~/heal",10000,1);
		SetPlayerPos(playerid,1624.2527,1821.0498,10.8203);
		SetPlayerFacingAngle(playerid,5.6779);
		SetPlayerSkin(playerid,276);
		GivePlayerWeapon(playerid,24,300);
		GivePlayerMoney(playerid, 20000);
		SetPlayerInterior(playerid,0);
		SetPlayerArmour(playerid, 100);
		return 1;
	}
	if(team[playerid] == 6) //S.T.A.R.S
	{
		SetPlayerColor(playerid,0x00FF00FF);
		SetPlayerTeam(playerid, 1);
		SetPlayerPos(playerid,1624.2527,1821.0498,10.8203);
		SetPlayerFacingAngle(playerid,5.6779);
 		SetPlayerSkin(playerid,287);
		GivePlayerWeapon(playerid,31,300);
 		GivePlayerWeapon(playerid,24,300);
		GivePlayerMoney(playerid, 20000);
		SetPlayerInterior(playerid,0);
		SetPlayerArmour(playerid, 100);
		return 1;
	}

	if(team[playerid] == 3)
	{
 		GameTextForPlayer(playerid,"ERROR",10000,1);
	}
	SetPlayerRandomSpawn(playerid);
	infected[playerid] = 0;
	return 1;
	}
I want a command like /putzombie <ID>, that puts a player in the zombie team
Reply
#5

is that what u want ?
Reply
#6

Yeah, sorry, I was on another forum posting some shizzle.
Reply
#7

Then just do:

pawn Code:
if(strcmp(cmdtext, "/putzombie", 10) == true)
{
    team[strval(cmdtext[11])] = 2;
    return 1;
}
With all the extras of course :P.
Reply
#8

Not sure if you use zcmd + sscanf, but here it is...

pawn Code:
CMD:putzombie(playerid, params[])
{
    new target;
    if(unformat(params, "u", target)) return SendClientMessage(playerid, 0xFAFAFAFA, "USAGE: /putzombie <playerid/name>");
    else if(target == INVALID_PLAYER_ID) return SendClientMessage(playerid, 0xFAFAFAFA, "Player not found");

    team[target] = 2;
    SetPlayerColor(target, ZRED);
    SetPlayerTeam(target, 2);
    SetPlayerHealth(target, 200);
    SetPlayerSkin(target, 162);
    GameTextForPlayer(target, "~r~Zombie: ~b~/hide", 10000, 1);
    return 1;
}
Reply
#9

uhm I don't use zcmd + sscanf
Reply
#10

pawn Code:
if(strcmp(cmdtext, "/putzombie", 10) == true)
{
    new id = strval(cmdtext[11]); //this is the id of the player whos team your trying to change
    //just do everything with 'id', such as:
    team[id] = 2; //change your players team
    //change their color, etc
    return 1;
}
strval checks the value of the string. The string is cmdtext. We but the 11 there because we want strval to read the string after the 11th character.

On the command itself, we put 10 because "/putzombie" is 10 characters long. That means it won't say "SERVER: unknown command" because we put an id after it.
Reply
#11

uhm that good

BTW: do u guys know any good team auto balance ?, or how to code one ?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)