Recently..
#1

pawn Код:
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;
}
I got this:
pawn Код:
SendClientMessage(playerid, 0xFF0000FF, "You have robbed someone recentlt, please wait...!");
And it is working....

but how to make something like this:
pawn Код:
format(string, sizeof(string), "%s(%d) has been robbed by SOMEONE ELSE, please wait...", targetname, targetid);
SendClientMessage(playerid, COLOR_ERROR, string);
Reply
#2

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 Код:
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 hope that i have helped
Reply
#3

Quote:
Originally Posted by rjjj
Посмотреть сообщение
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 Код:
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 hope that i have helped
I already knew that :P But that is not my problem... And i dont know how to explain it better =/ i have bad english =/ =/
Reply
#4

Quote:
Originally Posted by rjjj
Посмотреть сообщение
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
He's asking how to make it return an error saying "This Player Has Been Robbed Recently By Another Player. Please Wait"
Reply
#5

What actually he wants, is next thing: Let`s say person A robbed person B recently. Now, if you try to rob person B, he wants to return a error, stating that person B was already robbed by someone ( person A ) recently ...

And no, I have no idea how to do that... sorry, just wanted to help you out, by clearing things up.
Reply
#6

Oh, ok, so, you should create a variable in the top of your gamemode to checks if the player was already robbed

Put:

pawn Код:
//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;
    }

I hope that i have helped
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)