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

[help] knife round problem.


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Artizy
Member
Join Date: Jun 2011
Location: Milan, Italy.
Old 05-05-2016 , 10:54   [help] knife round problem.
Reply With Quote #1

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 is offline
Artizy
Member
Join Date: Jun 2011
Location: Milan, Italy.
Old 05-06-2016 , 12:13   Re: [help] knife round problem.
Reply With Quote #2

Nobody?
Artizy is offline
Drissdev1
Senior Member
Join Date: Jun 2014
Old 05-06-2016 , 18:39   Re: [help] knife round problem.
Reply With Quote #3

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

__________________
Drissdev1 is offline
siriusmd99
Veteran Member
Join Date: Oct 2013
Location: Republic of Moldova
Old 05-07-2016 , 06:21   Re: [help] knife round problem.
Reply With Quote #4

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;


Last edited by siriusmd99; 05-08-2016 at 16:43.
siriusmd99 is offline
Artizy
Member
Join Date: Jun 2011
Location: Milan, Italy.
Old 05-07-2016 , 08:30   Re: [help] knife round problem.
Reply With Quote #5

Now it's work (strip_user_weapons), but all players don't receive the knife.
Artizy is offline
siriusmd99
Veteran Member
Join Date: Oct 2013
Location: Republic of Moldova
Old 05-07-2016 , 10:38   Re: [help] knife round problem.
Reply With Quote #6

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.
siriusmd99 is offline
Artizy
Member
Join Date: Jun 2011
Location: Milan, Italy.
Old 05-07-2016 , 16:08   Re: [help] knife round problem.
Reply With Quote #7

Quote:
Originally Posted by siriusmd99 View Post
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.
Artizy is offline
siriusmd99
Veteran Member
Join Date: Oct 2013
Location: Republic of Moldova
Old 05-08-2016 , 03:15   Re: [help] knife round problem.
Reply With Quote #8

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.

Last edited by siriusmd99; 05-08-2016 at 03:16.
siriusmd99 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 10:35.


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