Raised This Month: $ Target: $400
 0% 

My code doens't work :(


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Apokalipsisa
Member
Join Date: May 2012
Old 09-04-2012 , 06:53   My code doens't work :(
Reply With Quote #1

Pls some one give me help.When i plant the bomb i want to slap terrorist after 10 seconds if he is camping.This is my noob code i've made but doesn't work.

PHP Code:
#include <amxmodx>
#include <cstrike>
#include <fakemeta>
#include <csx>


public plugin_init()
{
    
register_plugin("Plant/Defuse The BOMB","1.0","Apokalipsisa")
}

public 
bomb_planted(id)
{
    
set_task(1.0,"check_defuse_camper")
}

public 
CheckMoving()
{
    static 
iStillCounter[33]
    static 
FloatfVelocity[3]
    
    new 
players[32],numi,id
    get_players
(players,num)
    
    for(
i=0;i<num;i++)
    {
        
id players[i]
        
        if(!
is_user_alive(id)) 
        {
            
pev(id,pev_velocity,fVelocity)
    
            if(
fVelocity[0] || fVelocity[1] || fVelocity[2])
            {
                
iStillCounter[id] = 0
            
}
            else
            {
                if (++
iStillCounter[id] >= 10)
                {
                    
user_slap(id,0)
                }
            }
        }
    }
}

public 
check_defuse_camper()
{
    new 
players[32],numi,id
    get_players
(players,num)
    
    for(
i=0;i<num;i++)
    {
        
id players[i]
        
        if(!
is_user_alive(id) && cs_get_user_team(id) == CS_TEAM_T)
        {
            
set_task(1.0,"CheckMoving"1029 __"b")
        }
    }

Apokalipsisa is offline
Liverwiz
Veteran Member
Join Date: Feb 2010
Location: Maryland
Old 09-04-2012 , 09:04   Re: My code doens't work :(
Reply With Quote #2

Put in print statements to print the velocity of players after the bomb is planted. It'll give you more information as to what's going on.
__________________
What an elegant solution to a problem that doesn't need solving....
Liverwiz is offline
Apokalipsisa
Member
Join Date: May 2012
Old 09-04-2012 , 09:20   Re: My code doens't work :(
Reply With Quote #3

Quote:
Originally Posted by Liverwiz View Post
Put in print statements to print the velocity of players after the bomb is planted. It'll give you more information as to what's going on.
ammmmm how to put them in print statements?You mean to put a chat message when it start checking so i can see if the code works?Sry for my bad english
Apokalipsisa is offline
Torge
Veteran Member
Join Date: Oct 2011
Old 09-04-2012 , 09:22   Re: My code doens't work :(
Reply With Quote #4

Quote:
Originally Posted by Apokalipsisa View Post
ammmmm how to put them in print statements?You mean to put a chat message when it start checking so i can see if the code works?Sry for my bad english
Yes, like:

PHP Code:
client_print(0print_chat"..."); 

Last edited by Torge; 09-04-2012 at 09:23.
Torge is offline
Apokalipsisa
Member
Join Date: May 2012
Old 09-04-2012 , 10:16   Re: My code doens't work :(
Reply With Quote #5

Ok first i put chat message in here:

PHP Code:
public bomb_planted(id)
{
    
set_task(1.0,"check_defuse_camper")
    
ColorChat(0,GREEN,"asdasdasd")

When i plant the bomb it shows me the message ASDASDASD.Then i remove it from here and place it there:

PHP Code:
public check_defuse_camper()
{
    new 
players[32],numi,id
    get_players
(players,num)
    
    for(
i=0;i<num;i++)
    {
        
id players[i]
        
        if(!
is_user_alive(id) && cs_get_user_team(id) == CS_TEAM_T)
        {
            
set_task(1.0,"CheckMoving"1029 __"b")
            
ColorChat(0,GREEN,"asdasdasd")
        }
    }

Well not it doesn't show me the message.Is there anything wrong with my loop?I dont get any runtime errors or something pls help.
Apokalipsisa is offline
Torge
Veteran Member
Join Date: Oct 2011
Old 09-04-2012 , 10:34   Re: My code doens't work :(
Reply With Quote #6

Shouldn't be the target alive if you're checking for moving ?

PHP Code:
if(!is_user_alive(id
I think that's wrong..
Torge is offline
Apokalipsisa
Member
Join Date: May 2012
Old 09-04-2012 , 10:43   Re: My code doens't work :(
Reply With Quote #7

Quote:
Originally Posted by Torge View Post
Shouldn't be the target alive if you're checking for moving ?

PHP Code:
if(!is_user_alive(id
I think that's wrong..
Well i check if player is alive whats wrong ?
Apokalipsisa is offline
Liverwiz
Veteran Member
Join Date: Feb 2010
Location: Maryland
Old 09-04-2012 , 11:00   Re: My code doens't work :(
Reply With Quote #8

Quote:
Originally Posted by Torge View Post
Shouldn't be the target alive if you're checking for moving ?

PHP Code:
if(!is_user_alive(id
I think that's wrong..
Quote:
Originally Posted by Apokalipsisa View Post
Well i check if player is alive whats wrong ?
That's checking if the user is dead ( [not]is_user_alive ). I was saying to print the velocity to the user, when it checks it. But, though velocity theoretically should work, it isn't as good as origin. You want to know if a user has moved, rather than is moving. So cache the user's origin and compare current origin to the cached origin.
it'll slap them off the bomb if they're defusing also. So youll have to keep that into account.
I say put a check of pev_button & IN_USE to see if they're defusing.

EDIT: Just read the other comments. use this line
Code:
if(is_user_alive(id) && cs_get_user_team(id) == CS_TEAM_T)
instead of what you have there now.
__________________
What an elegant solution to a problem that doesn't need solving....

Last edited by Liverwiz; 09-04-2012 at 11:03.
Liverwiz is offline
Apokalipsisa
Member
Join Date: May 2012
Old 09-04-2012 , 11:27   Re: My code doens't work :(
Reply With Quote #9

Quote:
Originally Posted by Liverwiz View Post
That's checking if the user is dead ( [not]is_user_alive ). I was saying to print the velocity to the user, when it checks it. But, though velocity theoretically should work, it isn't as good as origin. You want to know if a user has moved, rather than is moving. So cache the user's origin and compare current origin to the cached origin.
it'll slap them off the bomb if they're defusing also. So youll have to keep that into account.
I say put a check of pev_button & IN_USE to see if they're defusing.

EDIT: Just read the other comments. use this line
Code:
if(is_user_alive(id) && cs_get_user_team(id) == CS_TEAM_T)
instead of what you have there now.
Man i use this line from the beginning.But the code doesn't work with it:
PHP Code:
if(!is_user_alive(id) && cs_get_user_team(id) == CS_TEAM_T
Well velocity is making me goo job.I've tried it another code and work perfectly.And thank you for telling me thath the code will slap the player who defuse the bomb,becouse he is stayng on one place i forgot this .So i want to ask you if i make the code like thath it will be better?

PHP Code:
if(!is_user_alive(id) return
        
        if(
cs_get_user_team(id) == CS_TEAM_T)
        {
            
set_task(1.0,"CheckMoving"1029 __"b")
        } 
Apokalipsisa is offline
Torge
Veteran Member
Join Date: Oct 2011
Old 09-04-2012 , 10:54   Re: My code doens't work :(
Reply With Quote #10

You're checking if player isn't alive...
Torge is offline
Reply


Thread Tools
Display Modes

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 08:10.


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