Raised This Month: $ Target: $400
 0% 

Problems with Random player


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
mysticssjgoku4
Veteran Member
Join Date: Jan 2005
Location: Chicago Heights, IL
Old 05-21-2010 , 14:12   Re: Problems with Random player
Reply With Quote #8

I too question why you give random players weapons only when a person spawns.

Your code was giving an m4 to id0, which would not work anyhow, but to be safe I threw a check in there. I also threw a check in there to make sure the person is alive. Test this code, but honestly not sure if it will work, been years since I coded something like this in pawn.

Code:
#include <amxmodx> #include <engine> #include <fakemeta> #include <fun> #include <hamsandwich> public plugin_init() {     register_plugin("Random Player", "0.1", "padilha007")     RegisterHam(Ham_Spawn, "player", "bacon_spawn", 1); } public bacon_spawn() {     new player;     if((player = GetRandomPlayer("a")) > 0)     {         give_item(player, "weapon_m4a1");     } } GetRandomPlayer(const flags[]="", const teamORname[]="") {     new players[32], pnum;     get_players(players, pnum, flags, teamORname);         new selected = 0;     while( is_user_alive((players[(selected = random(pnum))])))     {         return players[selected];     }     return 0; }
__________________


Last edited by mysticssjgoku4; 05-21-2010 at 14:21.
mysticssjgoku4 is offline
Send a message via AIM to mysticssjgoku4 Send a message via MSN to mysticssjgoku4
 



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

Forum Jump


All times are GMT -4. The time now is 03:38.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode