AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   [help] knife round problem. (https://forums.alliedmods.net/showthread.php?t=282373)

Artizy 05-05-2016 10:54

[help] knife round problem.
 
Only me i get 0 money and knife, others players get money and pistol when i execute the command. What is wrong with him?

This is the plugin.
Code:

#include <amxmodx>
#include <hamsandwich>
#include <cstrike>
#include <fun>

new bool:knife

public plugin_init()
{
        register_plugin
        (
                .plugin_name = "Knife Plugin",
                .version = "1.0",
                .author = "Artizy"
        )
        register_clcmd("say /knife","CmdSayKnife")
       
        RegisterHam(Ham_Spawn,"player","RoundRestart", 1)
}
public CmdSayKnife(id)
{
        if(get_user_flags(id) & ADMIN_KICK)
        {
                server_cmd("sv_restart 1")
                server_cmd("mp_freezetime 0")
                server_cmd("mp_startmoney 800")
                client_print(0,print_chat,"TEXT")
                knife = true
        }
}
public RoundRestart(id)
{
        if(knife)
        {
                if(is_user_alive(id))
                {
                        strip_user_weapons(id)
                        cs_set_user_money(id,0)
                        give_item(id,"weapon_knife")
                        knife = false
                }
        }
}


Artizy 05-06-2016 12:13

Re: [help] knife round problem.
 
Nobody?

Drissdev1 05-06-2016 18:39

Re: [help] knife round problem.
 
Test ples
PHP Code:

#include <amxmodx>
#include <hamsandwich>
#include <cstrike>
#include <fun>

new bool:knife

public plugin_init() 
{
    
register_plugin
    
(
        .
plugin_name "Knife Plugin",
        .
version "1.0",
        .
author "Artizy"
    
)
    
register_clcmd("say /knife","CmdSayKnife")
    
    
RegisterHam(Ham_Spawn,"player","RoundRestart"1)
}
public 
CmdSayKnife(id)
{
    if(
get_user_flags(id) & ADMIN_KICK)
    {
        
server_cmd("sv_restart 1")
        
server_cmd("mp_freezetime 0")
        
server_cmd("mp_startmoney 800")
        
client_print(0,print_chat,"TEXT")
        
knife true
    
}
}
public 
RoundRestart(id)
{
    if(
knife)
    {
        for (new 
1<= get_maxplayers(); i++) 
        {
            if (
is_user_alive(i)) 
            {
                
strip_user_weapons(i)
                
cs_set_user_money(i,0)
                
give_item(i,"weapon_knife")
            }
        }
    }
    
knife false



siriusmd99 05-07-2016 06:21

Re: [help] knife round problem.
 
Drissdev1, your code is worse then thread's author.
Ham spawn is for every player in part , you loop all players on every player spawn.
If there are 32 players then you strip their weapons 32 times.
In this case if you want to do knife= false then you shall use new round event and loop all players with a task:

PHP Code:

#include <amxmodx>
#include <cstrike>
#include <fun>

#define TASK_SW 11442

new bool:knife
new caller;

public 
plugin_init() 
{
    
register_plugin
    
(
        .
plugin_name "Knife Plugin",
        .
version "1.0",
        .
author "Artizy"
    
)
    
register_clcmd("say /knife","CmdSayKnife")
    
register_event("HLTV""event_new_round""a""1=0""2=0")  
}

public 
event_new_round(){

  if(
knife){
  if(
task_exists(TASK_SW))
  
remove_task(TASK_SW)
  
set_task(1.5"set_weapons"TASK_SW)
  }

}

public 
CmdSayKnife(id)
{
    if(
get_user_flags(id) & ADMIN_KICK)
    {
        
knife true
        caller 
id;
        
server_cmd("sv_restart 1")
        
server_cmd("mp_freezetime 0")
        
server_cmd("mp_startmoney 800")
        
client_print(0,print_chat,"[AMXX] KNIFE ROUND ENABLED.")
        return 
PLUGIN_CONTINUE;
    }
    return 
PLUGIN_HANDLED;
}

public 
set_weapons()
{
    new 
iPlayers[32], iPlayersNumiid;
    
get_players(iPlayersiPlayersNum"a")
    for (
0iPlayersNum; ++i)
    {
      
id iPlayers[i]
    
      
strip_user_weapons(id)
          
give_item(id,"weapon_knife")
        if(
caller == id){
           
cs_set_user_money(id,0)
        }else{
           
give_item(id,"weapon_deagle")
        }
    }
    
knife false;



Artizy 05-07-2016 08:30

Re: [help] knife round problem.
 
Now it's work (strip_user_weapons), but all players don't receive the knife.

siriusmd99 05-07-2016 10:38

Re: [help] knife round problem.
 
I didn't know you want knife to players too, because you said you shall have knife and they shall have pistol.
I edited the code above. You can recompile.

Artizy 05-07-2016 16:08

Re: [help] knife round problem.
 
Quote:

Originally Posted by siriusmd99 (Post 2417396)
I didn't know you want knife to players too, because you said you shall have knife and they shall have pistol.
I edited the code above. You can recompile.

Tx bro, now is working.

siriusmd99 05-08-2016 03:15

Re: [help] knife round problem.
 
Oh sorry, I forgot to delete hamsandwich from the top of plugin. It's not needed because I haven't used ham spawn. You can recompile plugin now, I edited the code.


All times are GMT -4. The time now is 18:41.

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