AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   My code doens't work :( (https://forums.alliedmods.net/showthread.php?t=195161)

Apokalipsisa 09-04-2012 06:53

My code doens't work :(
 
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")
        }
    }



Liverwiz 09-04-2012 09:04

Re: My code doens't work :(
 
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.

Apokalipsisa 09-04-2012 09:20

Re: My code doens't work :(
 
Quote:

Originally Posted by Liverwiz (Post 1791112)
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

Torge 09-04-2012 09:22

Re: My code doens't work :(
 
Quote:

Originally Posted by Apokalipsisa (Post 1791138)
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"..."); 


Apokalipsisa 09-04-2012 10:16

Re: My code doens't work :(
 
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.

Torge 09-04-2012 10:34

Re: My code doens't work :(
 
Shouldn't be the target alive if you're checking for moving ?

PHP Code:

if(!is_user_alive(id

I think that's wrong..

Apokalipsisa 09-04-2012 10:43

Re: My code doens't work :(
 
Quote:

Originally Posted by Torge (Post 1791200)
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 ?

Torge 09-04-2012 10:54

Re: My code doens't work :(
 
You're checking if player isn't alive...

Apokalipsisa 09-04-2012 10:58

Re: My code doens't work :(
 
Quote:

Originally Posted by Torge (Post 1791228)
You're checking if player isn't alive...

well then i have to put "return"?So then i check if player isn't Terrorist ?Maybe it should be CS_TEAM_CT?SO can i fixe by puting only return in the end of the checks

Torge 09-04-2012 10:59

Re: My code doens't work :(
 
Quote:

Originally Posted by Apokalipsisa (Post 1791232)
well then i have to put "return"?So then i check if player isn't Terrorist ?Maybe it should be CS_TEAM_CT?SO can i fixe by puting only return in the end of the checks

Just do:

PHP Code:

if (is_user_alive(id)) 

If you want, you can use return; if target isn't alive.


All times are GMT -4. The time now is 08:10.

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