public OnPlayerCommandText(playerid, cmdtext[]) { new giveplayerid; new cmd[128], idx; if(strcmp(cmd, "/kick", true) == 0) { new kicker[128]; new tmp[128]; tmp = strtok(cmdtext, idx); { if(!strlen(tmp)) { SendClientMessage(playerid, 0xFFFFFFFF, "Use /kick [playerid]"); return 1; } giveplayerid = ReturnUser(tmp); if(IsPlayerConnected(giveplayerid)) { format(kicker, sizeof(kicker), "You have kicked Player ID : %d from the server.", giveplayerid); SendClientMessage(playerid, 0xFFFFFFFF, kicker); Kick(strval(tmp)); return 1; } } } if(strcmp(cmd, "/ban", true) == 0) { new tmp[128]; tmp = strtok(cmdtext, idx); { if(!strlen(tmp)) { SendClientMessage(playerid, 0xFFFFFFFF, "Use /ban [playerid]"); return 1; } Ban(strval(tmp)); return 1; } } if(strcmp(cmd, "/afk", true) == 0) { GetPlayerName(playerid, pName, MAX_PLAYER_NAME); strins(pName, "[AFK]", 0); SetPlayerName(playerid, pName); return 1; } if(strcmp(cmd, "/giveplayergun", true) == 0) { new tmp[128]; tmp = strtok(cmdtext, idx); if(!strlen(tmp)) { SendClientMessage(playerid, 0xFFFFFFFF, "Use /giveplayergun [playerid] [gun-id]"); return 1; } new gunidstring[128]; new gunget; new gun; gunget = ReturnUser(tmp); gun = strvalEx(tmp); tmp = strtok(cmdtext, idx); if(strlen(tmp) == 0) return SendClientMessage(playerid, 0xFFFFFFFF, "You know the guns."); if(IsPlayerConnected(gunget)) { GivePlayerWeapon(gunget, gun, 99999); format(gunidstring, sizeof(gunidstring), "Admin %s has give you the weapon ID : %d", playerid, gun); SendClientMessage(gunget, 0xFFFFFFFF, gunidstring); } else { SendClientMessage(playerid, 0xFFFFFFFF, "That player is offline!"); } return 1; } return 0; }
new cmd[128], idx; if(strcmp(cmd, "/kick", true) == 0)
if (strcmp(cmdtext, "/kick", true) == 0) // u shoulda been comparing to cmdtext { }
i dont code in pawno anymore, but something is very wrong here.
Код:
new cmd[128], idx; if(strcmp(cmd, "/kick", true) == 0) Код:
if (strcmp(cmdtext, "/kick", true) == 0) // u shoulda been comparing to cmdtext { } |
public OnPlayerCommandText(playerid, cmdtext[])
{
new giveplayerid;
new cmd[128], idx;
if(strcmp(cmd, "/kick", true) == 0)
{
new kicker[128];
new tmp[128];
tmp = strtok(cmdtext, idx);
if(!strlen(tmp))
{
SendClientMessage(playerid, 0xFFFFFFFF, "Use /kick [playerid]");
return 1;
}
giveplayerid = ReturnUser(tmp);
if(IsPlayerConnected(giveplayerid))
{
format(kicker, sizeof(kicker), "You have kicked Player ID : %d from the server.", giveplayerid);
SendClientMessage(playerid, 0xFFFFFFFF, kicker);
Kick(strval(tmp));
}
return 1;
}
if(strcmp(cmd, "/ban", true) == 0)
{
new tmp[128];
tmp = strtok(cmdtext, idx);
if(!strlen(tmp))
{
SendClientMessage(playerid, 0xFFFFFFFF, "Use /ban [playerid]");
return 1;
}
Ban(strval(tmp));
return 1;
}
if(strcmp(cmdtext, "/afk", true) == 0)
{
GetPlayerName(playerid, pName, MAX_PLAYER_NAME);
strins(pName, "[AFK]", 0);
SetPlayerName(playerid, pName);
return 1;
}
if(strcmp(cmd, "/giveplayergun", true) == 0)
{
new tmp[128];
tmp = strtok(cmdtext, idx);
if(!strlen(tmp))
{
SendClientMessage(playerid, 0xFFFFFFFF, "Use /giveplayergun [playerid] [gun-id]");
return 1;
}
new gunidstring[128];
new gunget;
new gun;
gunget = ReturnUser(tmp);
gun = strvalEx(tmp);
tmp = strtok(cmdtext, idx);
if(strlen(tmp) == 0) return SendClientMessage(playerid, 0xFFFFFFFF, "You know the guns.");
if(IsPlayerConnected(gunget))
{
GivePlayerWeapon(gunget, gun, 99999);
format(gunidstring, sizeof(gunidstring), "Admin %s has give you the weapon ID : %d", playerid, gun);
SendClientMessage(gunget, 0xFFFFFFFF, gunidstring);
}
else { SendClientMessage(playerid, 0xFFFFFFFF, "That player is offline!"); }
return 1;
}
return 0;
}
public OnPlayerCommandText(playerid, cmdtext[]) { if(strcmp(cmdtext, "/noparamcommand", true) == 0) // commands without parameter, compares cmdtext { // do something return 1; } new cmd[128], idx; cmd = strtok(cmdtext, idx); // you forgot this, this is the string of the command if(strcmp(cmd, "/kick", true) == 0) // commands with parameter, compares cmd { new tmp[128]; tmp = strtok(cmdtext, idx); // this is actually string of the parameter // do something return 1; } return 0; }