01.08.2010, 20:50
I am working on a TDM, having a few problems, I know what they are, just not how to fix them. It seems that the cmds only work on ID : 0 (ex. /jail 6) 0 goes to jail. (ex. pm 6) 0 gets pm.
pawn Код:
if(strcmp(cmd, "/jail", true) == 0)
{
if(AccountInfo[playerid][Logged] == 1)
{
if(AccountInfo[playerid][AdminLevel] >= 1)
{
tmp = strtok(cmdtext, idx);
if(!strlen(tmp))
{
SendClientMessage(playerid, ORANGE, "USAGE: /jail [playerid]");
return 1;
}
if (giveplayerid != INVALID_PLAYER_ID)
{
new pname[MAX_PLAYER_NAME];
GetPlayerName(giveplayerid, pname, sizeof(pname));
SetPlayerInterior(giveplayerid, 3);
SetPlayerPos(giveplayerid, 197.3299, 174.8432, 1003.0234);
SendClientMessage(giveplayerid, WHITE, "[Info]: You have been jailed!");
format(string, sizeof(string), "[Info]: %s has been jailed!",pname);
SendClientMessageToAll(WHITE, string);
ResetPlayerWeapons(giveplayerid);
}
else SendClientMessage(playerid, RED, "Player is not active.");
}
else SendClientMessage(playerid, RED, "You're not an admin with the required level.");
}
else SendClientMessage(playerid, RED, "Error: You need to be logged in to do that!");
return 1;
}
if(strcmp(cmd, "/unjail", true) == 0)
{
if(AccountInfo[playerid][Logged] == 1)
{
if(AccountInfo[playerid][AdminLevel] >= 1)
{
tmp = strtok(cmdtext, idx);
if(!strlen(tmp))
{
SendClientMessage(playerid, ORANGE, "USAGE: /injail [playerid]");
return 1;
}
if (giveplayerid != INVALID_PLAYER_ID)
{
new pname[MAX_PLAYER_NAME];
GetPlayerName(giveplayerid, pname, sizeof(pname));
SetPlayerInterior(giveplayerid, 0);
SetPlayerTeamSpawn(giveplayerid);
SendClientMessage(giveplayerid, WHITE, "[Info]: You have been unjailed!");
format(string, sizeof(string), "[Info]: %s has been unjailed!",pname);
SendClientMessageToAll(WHITE, string);
}
else SendClientMessage(playerid, RED, "Player is not active.");
}
else SendClientMessage(playerid, RED, "You're not an admin with the required level.");
}
else SendClientMessage(playerid, RED, "Error: You need to be logged in to do that!");
return 1;
}
if(strcmp(cmd, "/pm", true) == 0)
{
if(IsPlayerConnected(playerid))
{
tmp = strtok(cmdtext, idx);
if(!strlen(tmp))
{
SendClientMessage(playerid, ORANGE, "USAGE: /pm [playerid] [text]");
return 1;
}
giveplayerid = strval(tmp);
if (IsPlayerConnected(giveplayerid))
{
if(giveplayerid != INVALID_PLAYER_ID)
{
new giveplayer[MAX_PLAYER_NAME];
GetPlayerName(playerid, sendername, sizeof(sendername));
GetPlayerName(giveplayerid, giveplayer, sizeof(giveplayer));
new length = strlen(cmdtext);
while ((idx < length) && (cmdtext[idx] <= ' '))
{
idx++;
}
new offset = idx;
new result[256];
while ((idx < length) && ((idx - offset) < (sizeof(result) - 1)))
{
result[idx - offset] = cmdtext[idx];
idx++;
}
result[idx - offset] = EOS;
if(!strlen(result))
{
SendClientMessage(playerid, COLOR_GRAD2, "USAGE: /pm [playerid/PartOfName] [text]");
return 1;
}
format(string, sizeof(string), "* PM from %s(ID: %d): %s", sendername, playerid, (result));
SendClientMessage(giveplayerid, YELLOW, string);
format(string, sizeof(string), "* PM to %s(ID: %d): %s", giveplayer, giveplayerid, (result));
SendClientMessage(playerid, YELLOW, string);
printf("%s: /w %s", sendername, result);
return 1;
}
}
else
{
format(string, sizeof(string), " %d is not an active player.", giveplayerid);
SendClientMessage(playerid, COLOR_GRAD1, string);
}
}
return 1;
}