Random weapons on mission [FIXED]
#1

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
Reply
#2

Код:
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);
	} 
}
Reply
#3

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.

Reply
#4

Sorry for the typo. I've modified my post.
Reply
#5

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
Reply
#6

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);
Reply
#7

nice ty

i tried it get 1 warning

Quote:

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

Reply
#8

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.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)