Robbing randomly 1.000-30.000
#1

Hey all. I've made a rob command and it always robs 10.000 dollars. How can I make it that it robs random between
1.000 and 30.000?
This is the command.
Might look messed up.

pawn Код:
COMMAND:rob(playerid,params[])
{
    new id;
    if(sscanf(params,"d",id)) return SendClientMessage(playerid,-1,"{F81414}*Command Failed* {FFFFFF}Correct Usage: {00C0FF}/rob [playerid]");
    if(Bit16_Get(g_Class,playerid) != 1) return SendClientMessage(playerid,-1,"{F81414}You're not a pickpocket!");
    if(Bit16_Get(jcooldown,playerid) == 1) return SendClientMessage(playerid,-1,"{F81414}You're still in the 5 minutes cooldown!");
    if(!IsPlayerInRangeOfPlayer(3,playerid,id)) return SendClientMessage(playerid,-1,"{F81414}You're not close enough to this player!");
    SendClientMessage(playerid,-1,"{00C0FF}You have to wait 5 minutes for another rob.");
    Bit16_Set(jcooldown,playerid,1);
    SetTimerEx("jackcool",300000,false,"i",playerid);
    TextDrawShowForPlayer(playerid,Textdraw7);
    TextDrawShowForPlayer(playerid,Textdraw8);
    Bit16_Set(jcount,playerid,300);
    format(String, sizeof(String), "%i", Bit16_Get(jcount,playerid));
    TextDrawSetString(Textdraw8,String);
    jacktimer = SetTimerEx("jcounting",1000,true,"i",playerid);
    SetPlayerWantedLevel(playerid,GetPlayerWantedLevel(playerid) +2);
    GetPlayerName(playerid,Name,sizeof(Name));
    format(String, sizeof(String), "{F81414}*Robbed* {00C0FF}%s {FFFFFF}has stolen {6EF83C}$10.000",Name);
    SendClientMessage(id,-1,String);
    GetPlayerName(id,Name,sizeof(Name));
    format(String, sizeof(String), "You've robbed {6EF83C}$10.000 {FFFFFF}from {00C0FF}%s",Name);
    SendClientMessage(playerid,-1,String);
    g_Cash[id] -= 10000;
    g_Cash[playerid] += 10000;
    return 1;
}
Reply
#2

pawn Код:
COMMAND:rob(playerid,params[])
{
    new id, cash;
    if(sscanf(params,"d",id)) return SendClientMessage(playerid,-1,"{F81414}*Command Failed* {FFFFFF}Correct Usage: {00C0FF}/rob [playerid]");
    if(Bit16_Get(g_Class,playerid) != 1) return SendClientMessage(playerid,-1,"{F81414}You're not a pickpocket!");
    if(Bit16_Get(jcooldown,playerid) == 1) return SendClientMessage(playerid,-1,"{F81414}You're still in the 5 minutes cooldown!");
    if(!IsPlayerInRangeOfPlayer(3,playerid,id)) return SendClientMessage(playerid,-1,"{F81414}You're not close enough to this player!");
    SendClientMessage(playerid,-1,"{00C0FF}You have to wait 5 minutes for another rob.");
    Bit16_Set(jcooldown,playerid,1);
    SetTimerEx("jackcool",300000,false,"i",playerid);
    TextDrawShowForPlayer(playerid,Textdraw7);
    TextDrawShowForPlayer(playerid,Textdraw8);
    Bit16_Set(jcount,playerid,300);
    format(String, sizeof(String), "%i", Bit16_Get(jcount,playerid));
    TextDrawSetString(Textdraw8,String);
    jacktimer = SetTimerEx("jcounting",1000,true,"i",playerid);
    SetPlayerWantedLevel(playerid,GetPlayerWantedLevel(playerid) +2);
    GetPlayerName(playerid,Name,sizeof(Name));
    cash = (random(29000)+1000); //Generates a random number between 1000 and 30000
    format(String, sizeof(String), "{F81414}*Robbed* {00C0FF}%s {FFFFFF}has stolen {6EF83C}$%d",Name, cash);
    SendClientMessage(id,-1,String);
    GetPlayerName(id,Name,sizeof(Name));
    format(String, sizeof(String), "You've robbed {6EF83C}$%d {FFFFFF}from {00C0FF}%s",cash,Name);
    SendClientMessage(playerid,-1,String);
    g_Cash[id] -= cash;
    g_Cash[playerid] += cash;
    return 1;
}
Reply
#3

Quote:
Originally Posted by OPremium
Посмотреть сообщение
pawn Код:
COMMAND:rob(playerid,params[])
{
    new id, cash;
    if(sscanf(params,"d",id)) return SendClientMessage(playerid,-1,"{F81414}*Command Failed* {FFFFFF}Correct Usage: {00C0FF}/rob [playerid]");
    if(Bit16_Get(g_Class,playerid) != 1) return SendClientMessage(playerid,-1,"{F81414}You're not a pickpocket!");
    if(Bit16_Get(jcooldown,playerid) == 1) return SendClientMessage(playerid,-1,"{F81414}You're still in the 5 minutes cooldown!");
    if(!IsPlayerInRangeOfPlayer(3,playerid,id)) return SendClientMessage(playerid,-1,"{F81414}You're not close enough to this player!");
    SendClientMessage(playerid,-1,"{00C0FF}You have to wait 5 minutes for another rob.");
    Bit16_Set(jcooldown,playerid,1);
    SetTimerEx("jackcool",300000,false,"i",playerid);
    TextDrawShowForPlayer(playerid,Textdraw7);
    TextDrawShowForPlayer(playerid,Textdraw8);
    Bit16_Set(jcount,playerid,300);
    format(String, sizeof(String), "%i", Bit16_Get(jcount,playerid));
    TextDrawSetString(Textdraw8,String);
    jacktimer = SetTimerEx("jcounting",1000,true,"i",playerid);
    SetPlayerWantedLevel(playerid,GetPlayerWantedLevel(playerid) +2);
    GetPlayerName(playerid,Name,sizeof(Name));
    cash = (random(29000)+1000); //Generates a random number between 1000 and 30000
    format(String, sizeof(String), "{F81414}*Robbed* {00C0FF}%s {FFFFFF}has stolen {6EF83C}$%d",Name, cash);
    SendClientMessage(id,-1,String);
    GetPlayerName(id,Name,sizeof(Name));
    format(String, sizeof(String), "You've robbed {6EF83C}$%d {FFFFFF}from {00C0FF}%s",cash,Name);
    SendClientMessage(playerid,-1,String);
    g_Cash[id] -= cash;
    g_Cash[playerid] += cash;
    return 1;
}
Thanks, it works fine! +rep
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)