Assigning a random number
#1

How would I assign a random 5 digit number to targetid? Here is the code:

Код:
CMD:agivecellphone(playerid,params[])
{
    if(PlayerInfo[playerid][pAdmin] < 4) return SendClientMessage(playerid,-1,"{AA3333}ERROR:{FFFFFF} Only administrators may use this command.");
    {
        new targetid, string[128], string2[128];
        if(sscanf(params,"u",targetid)) return SendClientMessage(playerid,-1,"{AA3333}USAGE:{FFFFFF} /agivecellphone (id)");
        if(PlayerInfo[targetid][pCellNumber] > 0) return SendClientMessage(playerid,-1,"{AA3333}ERROR:{FFFFFF} Player already has a cellphone.");
        {
            // Assign a random 5 digit number to targetid, PlayerInfo[targetid][pCellNumber]
            format(string,128,"{AA3333}AdminCMD:{FFFFFF} You have given %s a cellphone.",RemoveUnderScore(targetid));
            SendClientMessage(playerid,-1,string);
            format(string2,128,"{AA3333}AdminCMD:{FFFFFF} You have been given a cellphone by an administrator.");
            SendClientMessage(targetid,-1,string2);
		}
	}
	return 1;
}
Reply
#2

pawn Код:
#define randomEx(%0,%1) floatround(random((%1) - (%0)) + (%0))

PlayerInfo[targetid][pCellNumber] = randomEx(10000, 99999);
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)