new RobbedRecently[MAX_PLAYERS];
forward RobbedRecent();
public OnFilterScriptInit()
{
SetTimer("RobbedRecent", Minutes(2), true);
return 1;
}
public RobbedRecent()
{
for(new i = 0; i < MAX_PLAYERS; i++)
{
if(RobbedRecently[i] == 1)
{
RobbedRecently[i] = 0;
return 1;
}
}
return 1;
}
SendClientMessage(playerid, 0xFF0000FF, "You have robbed someone recentlt, please wait...!");
format(string, sizeof(string), "%s(%d) has been robbed by SOMEONE ELSE, please wait...", targetname, targetid);
SendClientMessage(playerid, COLOR_ERROR, string);
new text[60];
new PLName[MAX_PLAYER_NAME];//Creates a variable that can hold a text
GetPlayerName(playerid, PLName, sizeof(PLName));//Get the name of the player and put it in the variable
format(text, sizeof(text), "%s(%d) has been robbed by SOMEONE ELSE, please wait...", PLName, playerid);//format the "text" variable to it be the frase with the player's name and id.
SendClientMessage(playerid, COLOR_ERROR,text);//Finally
I did not understand your problem, but i think that you want to know how to use format function to show the name and the ID of the player
![]() Please, give us more informations about your problem. Well, i think that it will solve your problem: pawn Код:
![]() |
I did not understand your problem, but i think that you want to know how to use format function to show the name and the ID of the player
![]() Please, give us more informations about your problem. I hope that i have helped ![]() |
//In The Top of your GameMode:
new Robbed[MAX_PLAYERS];
//So, here a example using strtok:
if(strcmp(cmd, "/rob", true) == 0)
{
tmp = strtok(cmdtext, idx);
if(!strlen(tmp))
{
SendClientMessage(playerid, 0xFFFFFFAA, "Type: /rob [id]");
return 1;
}
new targetid = strval(tmp);
new targetname[MAX_PLAYER_NAME];
GetPlayerName(targetid, targetname, MAX_PLAYER_NAME);
if(Robbed[targetid] == 1)//IF the player was already robbed
{
format(string, sizeof(string), "%s(%d) has been robbed by SOMEONE ELSE, please wait...", targetname, targetid);
SendClientMessage(playerid, COLOR_ERROR, string);//will show the error message
}
else//else if the player was not already robbed..
{
Robbed[targetid] = 1;//Will set the player as a robbed player
}
return 1;
}