AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   WTH is wrong in this 3 line code? (https://forums.alliedmods.net/showthread.php?t=228871)

devWaleed 10-28-2013 14:16

WTH is wrong in this 3 line code?
 
WTH is wrong here?

PHP Code:

public on_player_death(){
    new 
Attacker    =    read_data(1);
    if(
get_user_frags(Attacker) > 1){
        
client_print(0print_chat"blarp!!!!!!!");
    }


It would print message when I get 3 kills not when I get 2 kills and If I do:

PHP Code:

public on_player_death(){
    new 
Attacker    =    read_data(1);
    if(
get_user_frags(Attacker) >= 1){
        
client_print(0print_chat"blarp!!!!!!!!!");
    }    


It would print when I get 3 kills. WHY??? What is wrong here???? Why won't it print after just 1 kill ????

mammapappa 10-28-2013 14:39

Re: WTH is wrong in this 3 line code?
 
> means more try only =

like this
Code:
public on_player_death(){     new Attacker    =    read_data(1);     if(get_user_frags(Attacker) = 1){         client_print(0, print_chat, "blarp!!!!!!!!!");     }     }

devWaleed 10-28-2013 15:04

Re: WTH is wrong in this 3 line code?
 
I know what it means, I mean >= should be "greater than or equal to" but whatever, I tried "==" but it wont work :\ It prints when I get 2 frags whereas it should print on frag 1.

akcaliberg 10-28-2013 17:26

Re: WTH is wrong in this 3 line code?
 
The function retrieves the frags just before the frag update, i think.

Delay the check with set_task for 0.5 seconds

hleV 10-28-2013 17:43

Re: WTH is wrong in this 3 line code?
 
How are you hooking player's death?

fysiks 10-29-2013 00:21

Re: WTH is wrong in this 3 line code?
 
It's likely because of the way that the death is hooked. If you are using Ham_Killed as a pre-hook, you should try a post-hook. If that doesn't fix it, register the DeathMsg event.

devWaleed 10-29-2013 05:32

Re: WTH is wrong in this 3 line code?
 
I am using DeathMsg event to check for player's death.

akcaliberg 10-29-2013 12:16

Re: WTH is wrong in this 3 line code?
 
Then, use Ham_Killed post or delay the check for about 0.5 seconds.

hornet 10-30-2013 04:47

Re: WTH is wrong in this 3 line code?
 
Quote:

Originally Posted by devWaleed (Post 2054082)
I am using DeathMsg event to check for player's death.

Post the full / real code.

devWaleed 10-30-2013 05:22

Re: WTH is wrong in this 3 line code?
 
Yes, adding delay solved it. Thanks :)


All times are GMT -4. The time now is 23:13.

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