Raised This Month: $ Target: $400
 0% 

Noob question for roundstart event


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
winds
Member
Join Date: Aug 2010
Old 11-11-2011 , 13:25   Noob question for roundstart event
Reply With Quote #1

I have a really noob question that I can't figure out the answer for. In the code below I am trying to strip every player in the server and give them all a knife at the beginning of a round if specialday is 1. As I have it now in the code, it only gives it to the admin that made the round but no one else. How would I make it strip and give a knife to everyone?
Thanks!

PHP Code:
public logevent_round_start()
{
    static 
iMaxPlayers;
    if ( !
iMaxPlayers )
        
iMaxPlayers get_maxplayers();

    for(new 
id 1id <= get_maxplayers(); id++) 
    {
        if ( 
SpecialDay == )
        {
            
strip_user_weapons(id);
            
give_item(id"weapon_knife")
            
set_hudmessage();
            
show_hudmessage(0"This is a knife only round");
            
SpecialDay 0
        

winds is offline
m0skVi4a
Senior Member
Join Date: May 2011
Location: Rousse, Bulgaria
Old 11-11-2011 , 13:31   Re: Noob question for roundstart event
Reply With Quote #2

From this code it would give to all players knife...
Post full code
m0skVi4a is offline
Send a message via Skype™ to m0skVi4a
winds
Member
Join Date: Aug 2010
Old 11-11-2011 , 13:42   Re: Noob question for roundstart event
Reply With Quote #3

Hopefully I am posting all that is relevant:

In a special rounds menu for admins they have an option to chose a Knife Only Round which would do this:
PHP Code:
        // Knife Only Round
        
case 3:
        {
            if(
b_Knife == false)
            {
                
ColorChat(idGREEN"^x04%s ^x01You selected Knife Only."TAG)
                
SpecialDay SpecialDay 1
                b_Knife 
true
            
}
            else
            {
                
ColorChat(idGREEN"^x04%s ^x01You already selected Knife Only."TAG)
            }
        } 
And then on round start it would do the previous code in my above post.
winds is offline
m0skVi4a
Senior Member
Join Date: May 2011
Location: Rousse, Bulgaria
Old 11-11-2011 , 13:45   Re: Noob question for roundstart event
Reply With Quote #4

PHP Code:
public logevent_round_start()
{
    static 
iMaxPlayers;
    if ( !
iMaxPlayers )
        
iMaxPlayers get_maxplayers();

    for(new 
id 1id <= get_maxplayers(); id++) 
    {
            
strip_user_weapons(id);
            
give_item(id"weapon_knife")
            
set_hudmessage();
            
show_hudmessage(0"This is a knife only round");
        } 
Like that?

Last edited by m0skVi4a; 11-11-2011 at 13:45.
m0skVi4a is offline
Send a message via Skype™ to m0skVi4a
Emp`
AMX Mod X Plugin Approver
Join Date: Aug 2005
Location: Decapod 10
Old 11-11-2011 , 14:02   Re: Noob question for roundstart event
Reply With Quote #5

You should check if the player is alive before stripping/giving because it could result in an error if you try to strip/give to an invalid player.
Emp` is offline
Send a message via AIM to Emp` Send a message via MSN to Emp` Send a message via Yahoo to Emp` Send a message via Skype™ to Emp`
m0skVi4a
Senior Member
Join Date: May 2011
Location: Rousse, Bulgaria
Old 11-11-2011 , 14:07   Re: Noob question for roundstart event
Reply With Quote #6

PHP Code:
public logevent_round_start()
{
    static 
iMaxPlayers;
    if ( !
iMaxPlayers )
        
iMaxPlayers get_maxplayers();

    for(new 
id 1id <= get_maxplayers(); id++) 
    {
        if(
is_user_alive(id)
        {
            
strip_user_weapons(id);
            
give_item(id"weapon_knife")
            
set_hudmessage();
            
show_hudmessage(0"This is a knife only round");
       }
    } 
m0skVi4a is offline
Send a message via Skype™ to m0skVi4a
winds
Member
Join Date: Aug 2010
Old 11-11-2011 , 14:12   Re: Noob question for roundstart event
Reply With Quote #7

Thanks guys, i'll add that to the code Emp.
Does anyone know what i'm doing wrong in my original code and why it isn't stripping all players?
winds is offline
m0skVi4a
Senior Member
Join Date: May 2011
Location: Rousse, Bulgaria
Old 11-11-2011 , 14:15   Re: Noob question for roundstart event
Reply With Quote #8

You have SpecialDay check that is set to 0 else if admin set it from menu to 1 it will strip weapons and give knife
m0skVi4a is offline
Send a message via Skype™ to m0skVi4a
winds
Member
Join Date: Aug 2010
Old 11-11-2011 , 14:30   Re: Noob question for roundstart event
Reply With Quote #9

Yeah exactly . However when the admin choses a knife round and specialday changes to 1, it will only strip and give a knife to the admin who chose it, not anyone else.
winds is offline
m0skVi4a
Senior Member
Join Date: May 2011
Location: Rousse, Bulgaria
Old 11-11-2011 , 14:33   Re: Noob question for roundstart event
Reply With Quote #10

There is no reason to do that in your code ;)
m0skVi4a is offline
Send a message via Skype™ to m0skVi4a
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 14:20.


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