AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Noob question for roundstart event (https://forums.alliedmods.net/showthread.php?t=171840)

winds 11-11-2011 13:25

Noob question for roundstart event
 
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
        



m0skVi4a 11-11-2011 13:31

Re: Noob question for roundstart event
 
From this code it would give to all players knife...
Post full code

winds 11-11-2011 13:42

Re: Noob question for roundstart event
 
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.

m0skVi4a 11-11-2011 13:45

Re: Noob question for roundstart event
 
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?

Emp` 11-11-2011 14:02

Re: Noob question for roundstart event
 
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.

m0skVi4a 11-11-2011 14:07

Re: Noob question for roundstart event
 
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");
       }
    } 


winds 11-11-2011 14:12

Re: Noob question for roundstart event
 
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?

m0skVi4a 11-11-2011 14:15

Re: Noob question for roundstart event
 
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

winds 11-11-2011 14:30

Re: Noob question for roundstart event
 
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.

m0skVi4a 11-11-2011 14:33

Re: Noob question for roundstart event
 
There is no reason to do that in your code ;)


All times are GMT -4. The time now is 14:20.

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