warn command - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: warn command (
/showthread.php?tid=318237)
warn command -
trulis - 14.02.2012
Can somebody help me with a command like /warn [playerid][reason] that adds a warn to the player for an rp gamemode ?
Re : warn command -
ricardo178 - 14.02.2012
Made it now.. Not tested:
pawn Код:
CMD:warn(playeid, params[])
{
if(PlayerInfo[playerid][AdminLevel] >= 1)
{
new id; new reason; new string[64];
if(!sscanf(params, "us", id, reason))
{
new Name[MAX_PLAYER_NAME]; new PlayerName[MAX_PLAYER_NAME];
GetPlayerName(playerid, Name, sizeof(Name));
GetPlayerName(id, PlayerName, sizeof(PlayerName));
format(string, sizeof(string), "Administrator %s has warned %s for %s", Name, PlayerName, reason);
SendClientMessageToAll(0xFFFFFFFF, string);
PlayerInfo[id][Warns] = PlayerInfo[id][Warns]+1;
return 1;
}
else return SendClientMessage(playerid, 0xFFFFFFFF, "Usage: /warn [PlayerId][Reason]");
}
else return SendClientMessage(playerid, 0xFFFFFFFF, "You are not allowed to use this command.");
}
Re: warn command -
trulis - 14.02.2012
your code didn't worked so i modified a /ban command and when i try to compile it get this error
Код:
C:\Documents and Settings\Trulis\Desktop\gta\gamemodes\gtarp.pwn(28897) : error 029: invalid expression, assumed zero
C:\Documents and Settings\Trulis\Desktop\gta\gamemodes\gtarp.pwn(28935) : error 029: invalid expression, assumed zero
Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase
2 Errors.
This is the code:
pawn Код:
if (strcmp(cmd,"/warn", true) == 0
{ //this is 28897
if(IsPlayerConnected(playerid))
{
tmp = strtok(cmdtext,idx);
if(!strlen(tmp))
{
SendClientMessage(playerid, COLOR_GRAD2, "USAGE: /warn [playerid/PartOfName]");
return 1;
}
giveplayerid = ReturnUser(tmp);
if (PlayerInfo[playerid][pAdmin] >= 1)
{
if(IsPlayerConnected(giveplayerid))
{
if(giveplayerid != INVALID_PLAYER_ID)
{
GetPlayerName(giveplayerid, giveplayer, sizeof(giveplayer));
GetPlayerName(playerid, sendername, sizeof(sendername));
new length = strlen(cmdtext);
while ((idx < length) && (cmdtext[idx] <= ' '))
{
idx++;
}
new offset = idx;
new result[64];
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: /warn [playerid/PartOfName] [reason]");
return 1;
}
new PlayerName[MAX_PLAYER_NAME];
GetPlayerName(playerid, PlayerName, sizeof(PlayerName));
format(string, sizeof(string), "AdmCmd: %s has warned %s for %s", giveplayer, sendername,) //this is 28935
format(string, sizeof(string), "AdmCmd: %s was warned by %s, reason: %s", giveplayer, sendername, (result))
SendClientMessageToAll(COLOR_LIGHTRED, string);
PlayerInfo[playerid][pWarns] = PlayerInfo[playerid][pWarns]+1;
return 1;
}
}//not connected
}
else
{
format(string, sizeof(string), " %d is not online.", giveplayerid);
SendClientMessage(playerid, COLOR_GRAD1, string);
}
}
return 1;
}
Re: warn command -
fordawinzz - 14.02.2012
pawn Код:
if (strcmp(cmd,"/warn", true) == 0)
{
if(IsPlayerConnected(playerid))
{
tmp = strtok(cmdtext,idx);
if(!strlen(tmp))
{
SendClientMessage(playerid, COLOR_GRAD2, "USAGE: /warn [playerid/PartOfName]");
return 1;
}
giveplayerid = ReturnUser(tmp);
if (PlayerInfo[playerid][pAdmin] >= 1)
{
if(IsPlayerConnected(giveplayerid))
{
if(giveplayerid != INVALID_PLAYER_ID)
{
GetPlayerName(giveplayerid, giveplayer, sizeof(giveplayer));
GetPlayerName(playerid, sendername, sizeof(sendername));
new length = strlen(cmdtext);
while ((idx < length) && (cmdtext[idx] <= ' '))
{
idx++;
}
new offset = idx;
new result[64];
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: /warn [playerid/PartOfName] [reason]");
return 1;
}
new PlayerName[MAX_PLAYER_NAME];
GetPlayerName(playerid, PlayerName, sizeof(PlayerName));
format(string, sizeof(string), "AdmCmd: %s has warned %s for %s", giveplayer, sendername);
format(string, sizeof(string), "AdmCmd: %s was warned by %s, reason: %s", giveplayer, sendername, (result));
SendClientMessageToAll(COLOR_LIGHTRED, string);
PlayerInfo[playerid][pWarns] = PlayerInfo[playerid][pWarns]+1;
return 1;
}
}//not connected
}
else
{
format(string, sizeof(string), " %d is not online.", giveplayerid);
SendClientMessage(playerid, COLOR_GRAD1, string);
}
}
return 1;
}
You should better use ZCMD/YCMD and SSCANF.
Re: warn command -
trulis - 20.02.2012
How can i make a command that removes warns from a player?