Raised This Month: $ Target: $400
 0% 

WTH is wrong in this 3 line code?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
devWaleed
Member
Join Date: Apr 2013
Location: Karachi, Pakistan
Old 10-28-2013 , 14:16   WTH is wrong in this 3 line code?
Reply With Quote #1

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 ????
devWaleed is offline
Send a message via Skype™ to devWaleed
mammapappa
Member
Join Date: Nov 2008
Old 10-28-2013 , 14:39   Re: WTH is wrong in this 3 line code?
Reply With Quote #2

> 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!!!!!!!!!");     }     }

Last edited by mammapappa; 10-28-2013 at 14:48.
mammapappa is offline
devWaleed
Member
Join Date: Apr 2013
Location: Karachi, Pakistan
Old 10-28-2013 , 15:04   Re: WTH is wrong in this 3 line code?
Reply With Quote #3

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.
devWaleed is offline
Send a message via Skype™ to devWaleed
akcaliberg
Senior Member
Join Date: Nov 2011
Location: Istanbul
Old 10-28-2013 , 17:26   Re: WTH is wrong in this 3 line code?
Reply With Quote #4

The function retrieves the frags just before the frag update, i think.

Delay the check with set_task for 0.5 seconds
akcaliberg is offline
hleV
Veteran Member
Join Date: Mar 2007
Location: Lithuania
Old 10-28-2013 , 17:43   Re: WTH is wrong in this 3 line code?
Reply With Quote #5

How are you hooking player's death?
__________________
hleV is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 10-29-2013 , 00:21   Re: WTH is wrong in this 3 line code?
Reply With Quote #6

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.
__________________
fysiks is online now
devWaleed
Member
Join Date: Apr 2013
Location: Karachi, Pakistan
Old 10-29-2013 , 05:32   Re: WTH is wrong in this 3 line code?
Reply With Quote #7

I am using DeathMsg event to check for player's death.
devWaleed is offline
Send a message via Skype™ to devWaleed
hornet
AMX Mod X Plugin Approver
Join Date: Mar 2010
Location: Australia
Old 10-30-2013 , 04:47   Re: WTH is wrong in this 3 line code?
Reply With Quote #8

Quote:
Originally Posted by devWaleed View Post
I am using DeathMsg event to check for player's death.
Post the full / real code.
hornet is offline
akcaliberg
Senior Member
Join Date: Nov 2011
Location: Istanbul
Old 10-29-2013 , 12:16   Re: WTH is wrong in this 3 line code?
Reply With Quote #9

Then, use Ham_Killed post or delay the check for about 0.5 seconds.
akcaliberg is offline
devWaleed
Member
Join Date: Apr 2013
Location: Karachi, Pakistan
Old 10-30-2013 , 05:22   Re: WTH is wrong in this 3 line code?
Reply With Quote #10

Yes, adding delay solved it. Thanks
devWaleed is offline
Send a message via Skype™ to devWaleed
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 23:14.


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