SA-MP Forums Archive
Halp [Random Amount] - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Halp [Random Amount] (/showthread.php?tid=395826)



Halp [Random Amount] - [CG]Milito - 27.11.2012

hi there!

I need some help, how do I make a pickup that gives you a random amount of money between 2000-5000. and how to write that "Random" amount in a SendClientMessage?


Re: Halp [Random Amount] - GWMPT - 27.11.2012

https://sampwiki.blast.hk/wiki/Random

Take a look on the link above.


Re: Halp [Random Amount] - [CG]Milito - 27.11.2012

-.-' It didn't help me


Re: Halp [Random Amount] - maramizo - 27.11.2012

pawn Код:
new pickup;

OnGameModeInit()
{
    //code
    pickup = CreatePickup(params..);
    return 1;
}

OnPlayerPickUpPickup(playerid, pickupid)
{
    if(pickupid == pickup)
    {
        new cash = 2000 + random(3000);
        new str[128];
        GivePlayerMoney(playerid, cash);
        format(str, 128, "You have picked up $%i.", cash);
        SendClientMessage(playerid, -1, playerid);
        return 1;
    }
}
Quick example.


Respuesta: Halp [Random Amount] - [CG]Milito - 30.11.2012

Thanks man! it worked. but now i wonder if it's possible with score and weapons. I mean
Give a random amount of score and a random weapon, is it possible?


Re: Halp [Random Amount] - [MM]RoXoR[FS] - 30.11.2012

Yes it's possible
pawn Код:
new money,score,wep;

OnGameModeInit()
{
    //code
    money = CreatePickup(params..);
    score = CreatePickup(params..);
    wep = CreatePickup(params..);
    return 1;
}

OnPlayerPickUpPickup(playerid, pickupid)
{
    if(pickupid == money)
    {
        new cash = 2000 + random(3000);
        new str[128];
        GivePlayerMoney(playerid, cash);
        format(str, 128, "You have picked up $%i.", cash);
        SendClientMessage(playerid, -1, playerid);
        return 1;
    }
    else if(pickupid == score)
    {
        new sc = random(10);
        SetPlayerScore(playerid, GetPlayerScore(playerid) + sc);
        new str[60];
        format(str,60,"We added %i score to your's",sc);
        SendClientMessage(playerid,-1,str);
    }
    else if(pickupid==wep)
    {
        new w=0;
        for(;w==0 || (w>=19 && w<=21);) { w=random(44);}
        new ammo = random(1000);
        GivePlayerWeapon(playerid,w,ammo);
        new str[128],wname[20];
        GetWeaponName(w,wname,20);
        if(w == 18) format(wname,20,"Molotov Cocktail");
        format(str,128,"You received %s(%i).",wname,ammo);
        SendClientMessage(playerid,-1,str);
    }
}