/rob command 1 problem 1 question -
Pawno_Master - 16.09.2009
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
Re: /rob command 1 problem 1 question -
Clavius - 16.09.2009
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);
Re: /rob command 1 problem 1 question -
Pawno_Master - 16.09.2009
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
Re: /rob command 1 problem 1 question -
Clavius - 16.09.2009
You have to use the previously created random value, which is 'randval', so change the 'money' to 'randval' in the formats.
Re: /rob command 1 problem 1 question -
eXchainZ-FoReVeR - 16.09.2009
Or just put an Static one, Like each rob... You earn $500
Re: /rob command 1 problem 1 question -
Pawno_Master - 16.09.2009
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
Re: /rob command 1 problem 1 question -
Clavius - 16.09.2009
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);
Re: /rob command 1 problem 1 question -
Pawno_Master - 16.09.2009
ty man youre just the BEST