SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help > Help Archive

 
 
Thread Tools Display Modes
Old 16/06/2010, 12:55 PM   #1
ArTisT
Big Clucker
 
Join Date: Mar 2009
Posts: 99
Reputation: 0
Default Random weapons on mission [FIXED]

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
ArTisT is offline  
Old 16/06/2010, 01:00 PM   #2
DJDhan
High-roller
 
DJDhan's Avatar
 
Join Date: Oct 2009
Location: Canada
Posts: 1,150
Reputation: 6
Default Re: Random weapons on mission

Code:
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);
	} 
}
__________________
DJDhan is offline  
Old 16/06/2010, 01:06 PM   #3
ArTisT
Big Clucker
 
Join Date: Mar 2009
Posts: 99
Reputation: 0
Default Re: Random weapons on mission

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 (c) 1997-2006, ITB CompuPhase


4 Errors.
ArTisT is offline  
Old 16/06/2010, 01:08 PM   #4
DJDhan
High-roller
 
DJDhan's Avatar
 
Join Date: Oct 2009
Location: Canada
Posts: 1,150
Reputation: 6
Default Re: Random weapons on mission

Sorry for the typo. I've modified my post.
__________________
DJDhan is offline  
Old 16/06/2010, 01:13 PM   #5
ArTisT
Big Clucker
 
Join Date: Mar 2009
Posts: 99
Reputation: 0
Default Re: Random weapons on mission

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
ArTisT is offline  
Old 16/06/2010, 01:40 PM   #6
Killerkid
Big Clucker
 
Join Date: Sep 2006
Location: UK
Posts: 197
Reputation: 1
Default Re: Random weapons on mission [FIXED]

Shorter version, just add the weapons to the array.
pawn Code:
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);
Killerkid is offline  
Old 16/06/2010, 01:46 PM   #7
ArTisT
Big Clucker
 
Join Date: Mar 2009
Posts: 99
Reputation: 0
Default Re: Random weapons on mission [FIXED]

nice ty

i tried it get 1 warning

Quote:
warning 219: local variable "i" shadows a variable at a preceding level
ArTisT is offline  
Old 16/06/2010, 01:52 PM   #8
Killerkid
Big Clucker
 
Join Date: Sep 2006
Location: UK
Posts: 197
Reputation: 1
Default Re: Random weapons on mission [FIXED]

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.
Killerkid is offline  
 

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Pick A Random Checkpoint For Mission? Alec24 Scripting Help 3 01/10/2012 12:48 AM
Random Weapons Spawn Freddy Z Help Archive 4 09/07/2010 12:15 PM
Guys this Warning is annoynning me -.- FIXED FIXED FIXED Ehab_Isaac101 Help Archive 14 10/03/2010 07:12 PM
Random Spawns.. [fixed] Lorenc_ Help Archive 2 14/02/2010 03:32 AM
New Mission Frikandel Help Archive 13 17/05/2009 12:35 PM


All times are GMT. The time now is 03:33 AM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.