Raised This Month: $ Target: $400
 0% 

can someone help me with this please!


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Black Rose
Veteran Member
Join Date: Feb 2011
Location: Stockholm, Sweden
Old 08-13-2013 , 18:46   Re: can someone help me with this please!
Reply With Quote #3

Your code won't work.
You're using get_players but you're completely ignoring the returned array players[].

So if you use get_players() and it will return an array like this:
players[] = { 1, 3, 6, 25 }

And then you loop players like this:
Code:
for(new id; id<inum;id++) {     server_print("%d", id) }
You would get: 0, 1, 2, 3
This would most likely result in a crash because it would try to call functions with players 0 and 2 who don't exist. On top of that, players 6 and 25 would be left out of the loop completely.

But if you use it like this:
Code:
for(new id; id<inum;id++) {     server_print("%d", players[id]) }
You would get: 1, 3, 6, 25

Here's what it should look like:
Code:
#include <amxmodx> #include <fun> public plugin_init() {     register_plugin("Drop weapons", "1.0", "FA");         register_logevent("round_end", 2, "1=Round_End"); } public round_end() {     new players[32],inum;     get_players(players,inum)     for(new id; id<inum;id++) {         if( is_user_alive(players[id]) )         {             strip_user_weapons(players[id]);             give_item(players[id], "weapon_knife");         }     } }
__________________

Last edited by Black Rose; 08-13-2013 at 18:49.
Black Rose is offline
 



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 15:52.


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