Raised This Month: $51 Target: $400
 12% 

can someone help me with this please!


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
maximus.toby
Junior Member
Join Date: Mar 2012
Old 08-13-2013 , 11:22   can someone help me with this please!
Reply With Quote #1

can someone help me how to code freeze at the end off the round, i alrdy have dropguns at the end of the round, but i want to, so they freeze to for like 1 sec
can someone help me with this Thank alrdy! xx


PHP 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 
idid<inum;id++) { 
       if( 
is_user_alive(id) )
    {
        
strip_user_weapons(id); 
        
give_item(id"weapon_knife"); 
    }
    } 

maximus.toby is offline
EpicMonkey
buttmonkey
Join Date: Feb 2012
Old 08-13-2013 , 11:42   Re: can someone help me with this please!
Reply With Quote #2

Go through the posts in this thread: https://forums.alliedmods.net/showthread.php?p=1262605
EpicMonkey is offline
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
maximus.toby
Junior Member
Join Date: Mar 2012
Old 08-15-2013 , 06:17   Re: can someone help me with this please!
Reply With Quote #4

Quote:
Originally Posted by Black Rose View Post
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");         }     } }
Thanks man, your code work perfect, thanks for the help! x
maximus.toby is offline
Reply



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 07:54.


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