Raised This Month: $ Target: $400
 0% 

[HAM] Outputs message twice


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
CodingIsHard
Junior Member
Join Date: Jul 2015
Old 10-15-2015 , 09:42   [HAM] Outputs message twice
Reply With Quote #1

PHP Code:
RegisterHam(Ham_Spawn"player""fwHamSpawnPlayer");

public 
fwHamSpawnPlayer(id) {
    
client_print_color(idRED"^3Spawned!");
    
set_task(5.0"fnNameProfit"id);
}

public 
fnNameProfit(id) {
    
client_print_color(idRED"^3Hi!");
    return 
PLUGIN_HANDLED;

Whenever i output it 5 seconds after the spawn, plugin prints it twice to the chat with a second delay. Am i doing anything wrong or is this supposed to happen? I tried to HAM_SUPERCED it, i am not a smart man.
Is there a IRC channel or anything for quick and (possibly) dumb questions i could ask occasionally if i can't find the answer after wasting 2 hours of my life.

Note: It only happens when the map begins -- on the very first round, second, third etc it only prints once.

Last edited by CodingIsHard; 10-15-2015 at 09:54. Reason: Extra info.
CodingIsHard is offline
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 10-15-2015 , 09:56   Re: [HAM] Outputs message twice
Reply With Quote #2

Register HAM as post and check is_user_alive before doing anything.
__________________
HamletEagle is offline
CodingIsHard
Junior Member
Join Date: Jul 2015
Old 10-15-2015 , 10:05   Re: [HAM] Outputs message twice
Reply With Quote #3

Done, done.
Still outputs twice.

The fact that only happens once the map starts(after change) makes me cringe..
UPDATE:Wrong, i was absolutely wrong.

Last edited by CodingIsHard; 10-15-2015 at 10:25. Reason: Updating updates.
CodingIsHard is offline
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 10-15-2015 , 10:13   Re: [HAM] Outputs message twice
Reply With Quote #4

You did not do add the check then. Check again. Spawn is called a first time when player is put in server (new player, no team yet, not alive), and it will be called again when player actually spawned in the current game (player is now alive). That's why you need to hook as post, and checking if player is alive.
__________________
Arkshine is offline
CodingIsHard
Junior Member
Join Date: Jul 2015
Old 10-15-2015 , 10:19   Re: [HAM] Outputs message twice
Reply With Quote #5

I just remembered what i saw the other day in a thread, you were correct just you didn't specify where i should've checked wether the player is alive.
I added the check into fwHamPlayerSpawn instead of checking it in my function, makes so much more sense now after the last post.

Cheers, +karma.
Is karma still a thing?

Last edited by CodingIsHard; 10-15-2015 at 10:22.
CodingIsHard 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 22:09.


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