/rob command 1 problem 1 question
#1

Hello,

I have one little problem with my /rob cmd
Everything works fine
The only wrong thing is
It is giving money to the robbed one
this is my code
Код:
dcmd_rob(playerid, params[])
{
new userid, string[128], targetsname[MAX_PLAYER_NAME], money, muggersname[MAX_PLAYER_NAME];
if (sscanf(params, "u", userid)) SendClientMessage(playerid, oranje, "USAGE: /rob [playerid]");
else
{
if(IsPlayerConnected(userid))
{
GetPlayerMoney(userid);

if(GetDistanceBetweenPlayers(playerid, userid) > 3)
{
  SendClientMessage(playerid, donkerrood, "You're not close enough.");
  return 1;
	}
if(gTeam[playerid] != TEAM_ROB) {
SendClientMessage(playerid,donkerrood,"You aren't a robber!");
}
if(gTeam[userid] == TEAM_ROB) {
SendClientMessage(playerid,donkerrood,"You cant rob a robber");
}
if(money < 0)
	{
  SendClientMessage(playerid, oranje, "That player doesn't have enough money to rob from. (0)");
  return 1;
	}
if(gTeam[playerid] == TEAM_ROB) {
GetPlayerName(playerid, muggersname, sizeof(muggersname));
GetPlayerName(userid, targetsname, sizeof(targetsname));

format(string, sizeof(string), "You have robbed $%d, from %s.", money, targetsname);
SendClientMessage(playerid, blauw, string);

format(string, sizeof(string), "You have been 'robbed'! You have lost $%d, %s stole it.", money, muggersname);
SendClientMessage(userid, donkerrood, string);

GivePlayerMoney(playerid,random(20000));
GivePlayerMoney(userid,random(0-20000)); }
	}
	}
return 1;
	}
i did GetPlayerMoney(userid,(random -20000));
but i dont know how to make it that it doesnt give money but actually takes it and give the exact amount to the player who robbed the other player so ("the robber")

and my question is

how can i make a timer so that someone cant use /rob everytime but after use he can use it again in 30 secs..
how to make that?
Thanks

From ekeleke
Reply
#2

pawn Код:
GivePlayerMoney(playerid,random(20000));
GivePlayerMoney(userid,random(0-20000));
is bad, since it gives random money to the playerid, and another random to the userid.
pawn Код:
new randval = random(GetPlayerMoney(userid));
GivePlayerMoney(playerid, randval);
GivePlayerMoney(userid, -randval);
Reply
#3

Thanks

i have one more problem

in the clientmessage he always sends

You have lost $0, Ekeleke has robbed you

The name part works but it always says $0 how could i fi that
Reply
#4

You have to use the previously created random value, which is 'randval', so change the 'money' to 'randval' in the formats.
Reply
#5

Or just put an Static one, Like each rob... You earn $500
Reply
#6

static is stupid xD srry but if i made a static one i knew anything on my own but i just want to learn how to make this and that and make a nice server and not make it easily for me ;p

but ehh

where should i replace money with randval because i dont understand everything of that part
Reply
#7

This part:
pawn Код:
format(string, sizeof(string), "You have robbed $%d, from %s.", randval, targetsname);
SendClientMessage(playerid, blauw, string);

format(string, sizeof(string), "You have been 'robbed'! You have lost $%d, %s stole it.", randval, muggersname);
SendClientMessage(userid, donkerrood, string);
Reply
#8

ty man youre just the BEST
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)