Originally Posted by [FAT]Klabauter[LST]
I think that it is giving you pistol every time because it is the first weapon you listed.
I tested this and it works, but it is still possible to get the same weapon more than once.
I don't know how to make it give 3 different weapons every time
PHP код:
stock giverandomweap(playerid)
{
new RandomWeapons = random(5);
switch(RandomWeapons)
{
case 0: return GivePlayerWeapon(playerid, 24, 500);
case 1: return GivePlayerWeapon(playerid, 27, 500);
case 3: return GivePlayerWeapon(playerid, 29, 500);
case 4: return GivePlayerWeapon(playerid, 31, 500);
case 5: return GivePlayerWeapon(playerid, 4, 1); // you can't have more than 1 knife
}
return 1;
}
public OnPlayerSpawn(playerid)
{
giverandomweap(playerid);
giverandomweap(playerid);
giverandomweap(playerid);
return 1;
}
I only know how to give a random weapon in each slot, I put assault and rifles together (seemed better that way)
go ahead and use this if you want:
PHP код:
stock giverandompistol(playerid)
{
new RandomWeapons = random(3);
switch(RandomWeapons)
{
case 0: return GivePlayerWeapon(playerid, 24, 150);
case 1: return GivePlayerWeapon(playerid, 23, 250);
case 2: return GivePlayerWeapon(playerid, 22, 350);
}
return 1;
}
stock giverandomshotty(playerid)
{
new RandomWeapons = random(3);
switch(RandomWeapons)
{
case 0: return GivePlayerWeapon(playerid, 25, 300);
case 1: return GivePlayerWeapon(playerid, 27, 200);
case 2: return GivePlayerWeapon(playerid, 26, 100);
}
return 1;
}
stock giverandomsmg(playerid)
{
new RandomWeapons = random(3);
switch(RandomWeapons)
{
case 0: return GivePlayerWeapon(playerid, 28, 500);
case 1: return GivePlayerWeapon(playerid, 32, 500);
case 2: return GivePlayerWeapon(playerid, 29, 500);
}
return 1;
}
stock giverandomrifle(playerid)
{
new RandomWeapons = random(4);
switch(RandomWeapons)
{
case 0: return GivePlayerWeapon(playerid, 34, 75);
case 1: return GivePlayerWeapon(playerid, 33, 200);
case 2: return GivePlayerWeapon(playerid, 30, 300);
case 3: return GivePlayerWeapon(playerid, 31, 250);
}
return 1;
}
stock giverandommelee(playerid)
{
new RandomWeapons = random(15);
switch(RandomWeapons)
{
case 0: return GivePlayerWeapon(playerid, 1, 1);
case 1: return GivePlayerWeapon(playerid, 2, 1);
case 2: return GivePlayerWeapon(playerid, 3, 1);
case 3: return GivePlayerWeapon(playerid, 4, 1);
case 4: return GivePlayerWeapon(playerid, 5, 1);
case 5: return GivePlayerWeapon(playerid, 6, 1);
case 6: return GivePlayerWeapon(playerid, 7, 1);
case 7: return GivePlayerWeapon(playerid, 8, 1);
case 8: return GivePlayerWeapon(playerid, 9, 1);
case 9: return GivePlayerWeapon(playerid, 10, 1);
case 10: return GivePlayerWeapon(playerid, 11, 1);
case 11: return GivePlayerWeapon(playerid, 12, 1);
case 12: return GivePlayerWeapon(playerid, 13, 1);
case 13: return GivePlayerWeapon(playerid, 14, 1);
case 14: return GivePlayerWeapon(playerid, 15, 1);
}
return 1;
}
public OnPlayerSpawn(playerid)
{
giverandompistol(playerid);
giverandomshotty(playerid);
giverandomsmg(playerid);
giverandomrifle(playerid);
giverandommelee(playerid);
return 1;
}
|