/Rob command need help ')
#1

Hello,

i am working on a /rob command

Im working with sscanf this is my command

Код:
		dcmd_rob(playerid, params[])
	{
  	new
	  id;
  	if(sscanf(params, "u", id)) return SendClientMessage(playerid, 0xFF0000AA, "Usage: /rob [id]");
  	else if(id == INVALID_PLAYER_ID) return SendClientMessage(playerid, 0xFF0000AA, "Player not found");
  	else if(GetDistanceBetweenPlayers(playerid,id) > 3) SendClientMessage(playerid,donkerrood,"The player is too far away");
  	else if(gTeam[playerid] != TEAM_ROB) { SendClientMessage(playerid,donkerrood,"You aren't a robber"); }
  	else if(gTeam[id] == TEAM_ROB) { SendClientMessage(playerid,donkerrood,"You can't Rob a Robber he's a friend!"); }
  	else if(gTeam[playerid] == TEAM_ROB) {
  	{
   	SendClientMessage(playerid,blauw,"You have robbed someone!!");
   	SendClientMessage(id,donkerrood,"You have been robbed!!");
   	GivePlayerMoney(playerid,18537);
   	GivePlayerMoney(id,-18537); }
  	}
  	return 1;
}

Ok now my question is how to make that if someone rob someone or if someone gets robbed that they can see the name from eachtoher for example Sendclientmessage(playerid,0x....,яou have been robbed by BLABLA!");

and that robbers randomly steal money so not the same money always if they rob someone and that the money of the robbed one cant get nagativre plz help

Reply
#2

Sorry for bump but i really need this
Reply
#3

http://forum.sa-mp.com/index.php?topic=114010.0
Reply
#4

About showing who robbed you;
first, add this stock to your script:
pawn Код:
stock GetPlayerName2(playerid)
{
    new pname[MAX_PLAYER_NAME];
    GetPlayerName(playerid, pname, sizeof(pname));
    return pname;
}
It returns playerid's name.

Now, you need to create a string, and format it like this:
pawn Код:
format(string, sizeof(string), "%s robbed you!", GetPlayerName2(playerid));
send the string as a client message for the victim (id), then:
pawn Код:
format(string, sizeof(string), "You have robbed %s!", GetPlayerName2(id));
send it again, this time for the robber.

For the random money, you need to get a random number, and check the victims money, if it's less than the random, just take al of his cash!
You could use RandomEx:
pawn Код:
stock RandomEx(min, max) // by ******
{
    return random(max - min) + min;
}
Reply
#5

Player beat me to it, oh well, I posted this anyway.

pawn Код:
dcmd_rob(playerid, params[])
{
    new userid, string[128], targetsname[MAX_PLAYER_NAME], money, muggersname[MAX_PLAYER_NAME];
    if (sscanf(params, "u", userid)) SendClientMessage(playerid, COLOR_WHITE, "SYNTAX - /mask [playerid]");
    else
    {
        if(IsPlayerConnected(userid))
        {
            GetPlayerMoney(userid);

            if(GetDistanceBetweenPlayers(playerid, userid) > 3)
            {
              SendClientMessage(playerid, COLOR_WHITE, "You're not close enough.");
              return 1;
            }
            if(money < 0)
            {
              SendClientMessage(playerid, COLOR_WHITE, "That player doesn't have enough money to rob from. (0)");
              return 1;
            }
           
            GetPlayerName(playerid, muggersname, sizeof(muggersname));
            GetPlayerName(userid, targetsname, sizeof(targetsname));
           
            format(string, sizeof(string), "You have robbed $%d, from %s.", money, targetsname);
            SendClientMessage(playerid, COLOR_WHITE, string);
           
            format(string, sizeof(string), "You have been 'mugged'! You have lost $%d, %s stole it.", money, muggersname);
            SendClientMessage(playerid, COLOR_WHITE, string);
           
            GivePlayerMoney(playerid, money);
        }
    }
    return 1;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)