SA-MP Forums Archive
Random weapons on mission [FIXED] - 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)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Random weapons on mission [FIXED] (/showthread.php?tid=154968)



Random weapons on mission [FIXED] - ArTisT - 16.06.2010

Quote:

ResetPlayerWeapons(i);
new shotgun=random(3);
if (shotgun==0) { GivePlayerWeapon(i, 25, 99); }
else if (shotgun==1) { GivePlayerWeapon(i, 26, 99); }
else if (shotgun==2) { GivePlayerWeapon(i, 27, 99); }

It gives to all different weapons if they join to the mission. I want that it should give to all the same weapons.

- fixed.. thanks to DJDhan


Re: Random weapons on mission - DJDhan - 16.06.2010

Код:
new shotgun=random(3);
new i;
if (shotgun==0) 
{ 
	for(i=0;i<MAX_PLAYERS;i++)
	{
		ResetPlayerWeapons(i);
		GivePlayerWeapon(i, 25, 99);
	} 
}
if (shotgun==1) 
{ 
	for(i=0;i<MAX_PLAYERS;i++)
	{
		ResetPlayerWeapons(i);
		GivePlayerWeapon(i, 26, 99);
	} 
}
if (shotgun==2) 
{ 
	for(i=0;i<MAX_PLAYERS;i++)
	{
		ResetPlayerWeapons(i);
		GivePlayerWeapon(i, 27, 99);
	} 
}



Re: Random weapons on mission - ArTisT - 16.06.2010

ty for help

but i get this errors

Quote:

C:\Dokumente und Einstellungen\Ab\Desktop\Project\MAIN SERVER\LA\gamemodes\la.pwn(44003) : error 017: undefined symbol "newi"
C:\Dokumente und Einstellungen\Ab\Desktop\Project\MAIN SERVER\LA\gamemodes\la.pwn(44003) : warning 205: redundant code: constant expression is zero
C:\Dokumente und Einstellungen\Ab\Desktop\Project\MAIN SERVER\LA\gamemodes\la.pwn(44003) : warning 215: expression has no effect
C:\Dokumente und Einstellungen\Ab\Desktop\Project\MAIN SERVER\LA\gamemodes\la.pwn(44003) : error 001: expected token: ")", but found ";"
C:\Dokumente und Einstellungen\Ab\Desktop\Project\MAIN SERVER\LA\gamemodes\la.pwn(44003) : error 036: empty statement
C:\Dokumente und Einstellungen\Ab\Desktop\Project\MAIN SERVER\LA\gamemodes\la.pwn(44003) : fatal error 107: too many error messages on one line

Compilation aborted.Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase


4 Errors.




Re: Random weapons on mission - DJDhan - 16.06.2010

Sorry for the typo. I've modified my post.


Re: Random weapons on mission - ArTisT - 16.06.2010

yo thanks i get now 3x same warning

C:\Dokumente und Einstellungen\Ab\Desktop\Project\SERVER\LA\gamemod es\la.pwn(44003) : warning 219: local variable "i" shadows a variable at a preceding level

btw is there a shorter way ? because if i put more guns i need much lines


Re: Random weapons on mission [FIXED] - Killerkid - 16.06.2010

Shorter version, just add the weapons to the array.
pawn Код:
new weapons[] = {25, 26, 27};
new rand = random(sizeof(weapons) + 1);
for(new i = 0; i < GetMaxPlayers(); i++) ResetPlayerWeapons(i), GivePlayerWeapon(i, weapons[rand], 99);



Re: Random weapons on mission [FIXED] - ArTisT - 16.06.2010

nice ty

i tried it get 1 warning

Quote:

warning 219: local variable "i" shadows a variable at a preceding level




Re: Random weapons on mission [FIXED] - Killerkid - 16.06.2010

Quote:
Originally Posted by ArTisT
nice ty

i tried it get 1 warning

Quote:

warning 219: local variable "i" shadows a variable at a preceding level

It's because you declared i somewhere else, it shouldn't cause any problems so you can ignore it.