SA-MP Forums Archive
Random Weapon - 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: Random Weapon (/showthread.php?tid=278557)



Random Weapon - Ironboy - 22.08.2011

<REMOVED>


Re: Random Weapon - =WoR=G4M3Ov3r - 22.08.2011

PHP Code:
GivePlayerWeapon(playeridweaponidammo);
    return 
1




Re: Random Weapon - Ironboy - 22.08.2011

Not that, its asking different questions so different weapons in each questions.


Re: Random Weapon - =WoR=G4M3Ov3r - 22.08.2011

PHP Code:
GivePlayerWeapon(playerid38500); // Minigun
GivePlayerWeapon(playerid28500); // Uzi
GivePlayerWeapon(playerid1650); // Grenade
GivePlayerWeapon(playerid43500); // Camera 
https://sampwiki.blast.hk/wiki/Weapons


Edit : Oh, Didn't see your Post.


Re: Random Weapon - Antonio [G-RP] - 22.08.2011

Add this:
NOTE: The code is not complete. Try finishing it.

pawn Code:
new wea = id1,id2,id3,id4,
      rand(4);
   
switch(rand) {
    case 1: {
        GivePlayerWeapon(playerid, id1, 100);
    }
    case 2: {
        GivePlayerWeapon(playerid, id2, 100);
    }



Re: Random Weapon - Ironboy - 22.08.2011

<REMOVED>


Re: Random Weapon - Antonio [G-RP] - 22.08.2011

No, I can't. It goes underneath:

pawn Code:
format(msg,sizeof(msg),"%s has solved a task successfully in %i seconds (Ans: %i)",name, GetTimerInSeconds(GetTickCount(),gServerData[E_START_TIME]), gServerData[E_ANSWER]);
        SendClientMessageToAll(blue,msg);
        print(msg);
Where id1,id2,etc is, you enter your desired weapon ids. You change rand to how many weapons you have listed and go from there. It will randomly select one of the weapons you've put in and give the player the weapon.


Re: Random Weapon - Jefff - 22.08.2011

pawn Code:
new WeaponID[] = {id1,id2,id3};
GivePlayerWeapon(playerid, WeaponID[random(sizeof(WeaponID))], 100);



Re: Random Weapon - Ironboy - 22.08.2011

ok thx for that but how can i get that weapon name?
I mean like this " First One who solve => %i + %i - %i + %i <= will get $1000 + WEAPON NAME" ?


Re: Random Weapon - Jefff - 22.08.2011

pawn Code:
stock ReturnWeaponName(weaponid)
{
    new weapname[64];
    GetWeaponName(weaponid,weapname,sizeof(weapname));
    return weapname;
}
new WeaponID[3] = {38,39,4};

new weap = WeaponID[random(sizeof(WeaponID))];
GivePlayerWeapon(playerid, weap, 100);
"First One who solve => %i + %i - %i + %i <= will get $1000 + %s",.......,ReturnWeaponName(weap)