Need Help - Jarnu - 22.05.2012
I want to know how to make Command.. /freezeteam and /getteam..
So that I can freeze a particular team. or teleport particular team..
Each reply would be apriciated. Thank You.
Re: Need Help -
jessejanssen - 22.05.2012
Could you give a little more information? How do you want to have an example? Do you use OnPlayerCommandText or you use includes like ZCMD etc etc etc?
Best regards,
Jesse
Re: Need Help - Jarnu - 22.05.2012
i use ZCMD.
like /get teleports a player to an admins pos.. but i want /getteam which teleports a particular team..
Re: Need Help -
jessejanssen - 22.05.2012
Okay, with ZCMD the '/getteam' command should be something like this:
pawn Код:
CMD:getteam(playerid, params[])
{
new string[110], idx, Float:X, Float:Y, Float:Z, teamtpd;
GetPlayerPos(playerid, X, Y, Z);
string = strtok(params, idx);
if(!strlen(string))
{
SendClientMessage(playerid, 0xFFFFFFFF, "USAGE: /getteam [TeamID]");
return 1;
}
for(new i; i < MAX_PLAYERS; i++)
{
if(Team[i] == string && teamtpd < 14) // 'Team[i]' should obviously be your team variable, but it should be playerid bound obviously.
{
switch(teamtpd)
{
case 0: SetPlayerPos(i, X+1, Y, Z);
case 1: SetPlayerPos(i, X+1, Y+1, Z);
case 2: SetPlayerPos(i, X, Y+1, Z);
case 3: SetPlayerPos(i, X+2, Y, Z);
case 4: SetPlayerPos(i, X+2, Y+2, Z);
case 5: SetPlayerPos(i, X, Y+2, Z);
case 6: SetPlayerPos(i, X+3, Y, Z);
case 7: SetPlayerPos(i, X+3, Y+3, Z);
case 8: SetPlayerPos(i, X, Y+3, Z);
case 9: SetPlayerPos(i, X+4, Y, Z);
case 10: SetPlayerPos(i, X+4, Y+4, Z);
case 11: SetPlayerPos(i, X, Y+4, Z);
case 12: SetPlayerPos(i, X+5, Y, Z);
case 13: SetPlayerPos(i, X+5, Y+5, Z);
case 14: SetPlayerPos(i, X, Y+5, Z);
}
teamtpd++;
}
}
return 1;
}
The command above will give you the ability to teleport 15 people out of one team to you. If you want to teleport more people/bigger teams you should add more 'case's and you should increase the teamtpd < XX then. If you will do that, and the teams get bigger then like 30 people, I would also take - numbers at the SetPlayerPos' so they spawn around you.
Here is the '/freezeteam' command:
pawn Код:
new TeamFrozen[MAX_TEAMS]; // You will have to define 'MAX_TEAMS' by yourself, depending on how much teams you have. You should do it like '#define MAX_TEAMS *number*' next to all of your other #defines.
CMD:freezeteam(playerid, params[])
{
new string[110], idx, string2[110], name[MAX_PLAYER_NAME], name2[MAX_PLAYER_NAME];
GetPlayerName(playerid, name, sizeof(name));
string = strtok(params, idx);
if(!strlen(string))
{
SendClientMessage(playerid, 0xFFFFFFFF, "USAGE: /freezeteam [TeamID]");
return 1;
}
if(TeamFrozen[string] == 0)
{
for(new i; i < MAX_PLAYERS; i++)
{
if(Team[i] == string) // 'Team[i]' should also here obviously be your team variable, but it should also here be playerid bound obviously.
{
GetPlayerName(i, name2, sizeof(name2));
CanPlayerMove(i, 0);
format(string2, sizeof(string2), "> %s has just frozen you.", name);
SendClientMessage(i, 0xFFFFFFFF, string2);
format(string2, sizeof(string2), "> You have just frozen %s.", name2);
SendClientMessage(playerid, 0xFFFFFFFF, string2);
}
}
}
else if(TeamFrozen[string] == 1)
{
for(new i; i < MAX_PLAYERS; i++)
{
if(Team[i] == string) // 'Team[i]' should also here obviously be your team variable, but it should also here be playerid bound obviously.
{
GetPlayerName(i, name2, sizeof(name2));
CanPlayerMove(i, 1);
format(string2, sizeof(string2), "> %s has just unfrozen you.", name);
SendClientMessage(i, 0xFFFFFFFF, string2);
format(string2, sizeof(string2), "> You have just unfrozen %s.", name2);
SendClientMessage(playerid, 0xFFFFFFFF, string2);
}
}
}
return 1;
}
This should be something like it, if I have helped you please rep+ me

..
Best regards,
Jesse
Re: Need Help - Jarnu - 22.05.2012
Код:
D:\Server Hosted\gamemodes\gm2.pwn(4116) : error 017: undefined symbol "MAX_TEAMS"
D:\Server Hosted\gamemodes\gm2.pwn(4116) : error 009: invalid array size (negative, zero or out of bounds)
D:\Server Hosted\gamemodes\gm2.pwn(4122) : error 017: undefined symbol "strtok"
D:\Server Hosted\gamemodes\gm2.pwn(4122) : error 033: array must be indexed (variable "string")
D:\Server Hosted\gamemodes\gm2.pwn(4128) : error 033: array must be indexed (variable "string")
D:\Server Hosted\gamemodes\gm2.pwn(4132) : error 017: undefined symbol "Team"
D:\Server Hosted\gamemodes\gm2.pwn(4132) : warning 215: expression has no effect
D:\Server Hosted\gamemodes\gm2.pwn(4132) : error 001: expected token: ";", but found "]"
D:\Server Hosted\gamemodes\gm2.pwn(4132) : error 029: invalid expression, assumed zero
D:\Server Hosted\gamemodes\gm2.pwn(4132) : fatal error 107: too many error messages on one line
Compilation aborted.Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase
9 Errors.
Errors D:
Re: Need Help -
jessejanssen - 22.05.2012
Sorry, you should place this in an include:
pawn Код:
strtok(const string[], &index)
{
new length = strlen(string);
while ((index < length) && (string[index] <= ' ')) { index++; }
new offset = index;
new result[20];
while ((index < length) && (string[index] > ' ') && ((index - offset) < (sizeof(result) - 1)))
{ result[index - offset] = string[index]; index++; }
result[index - offset] = EOS;
return result;
}
And as I said you will have to define your 'MAX_TEAMS' yourself by the ammount of teams you have. You should also change the 'Team[i]' to the variable what holds the team for a player.
Best regards,
Jesse