Raised This Month: $ Target: $400
 0% 

Spread Values


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Wasc
Junior Member
Join Date: Apr 2011
Old 10-25-2011 , 14:10   Spread Values
Reply With Quote #1

Good evening ,or morning...don't know
I wanna make plugin which shows message if player defused bomb 1 second before explosion, but I encountered an error. How can I make value, that uses not only in one public? Hope you understood.
Code:
#include <amxmodx>
#include <amxmisc>

public plugin_init() {
    register_plugin("unnamed","1.0","unnamed")
    register_logevent("BombPlantComplete",3,"2=Planted_The_Bomb")
    register_logevent("BombDefused",3,"2=Defused_The_Bomb")
}

public BombPlantComplete(){
    new Float:BombTimer = get_gametime()
    new Float:cooldown = BombTimer + 29.0
}

public BombDefused(){    
    if(BombTimer >= cooldown)
        client_print(0,print_chat,"Message")
}
Error is "undefined symbol BombTimer and cooldown", but I defined them in BombPlantComplete.
Thanks for participating
Wasc is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 10-25-2011 , 15:08   Re: Spread Values
Reply With Quote #2

define the 2 variables globally (above plugin_init, under includes), assign the values the same basically just remove "new Float:" from both.
__________________
Bugsy is offline
Old 10-25-2011, 15:46
Bugsy
This message has been deleted by Bugsy. Reason: double
Wasc
Junior Member
Join Date: Apr 2011
Old 10-25-2011 , 16:25   Re: Spread Values
Reply With Quote #3

If I understood you correctly, variables which assigned in globally will changes from event to event globally too?
Code:
#include <amxmodx> 
#include <amxmisc>

new Float:BombTimer = get_gametime() 
new Float:cooldown = BombTimer + 29.0 
public plugin_init() {
     register_plugin("unnamed","1.0","unnamed")
     register_logevent("BombPlantComplete",3,"2=Planted_The_Bomb")
     register_logevent("BombDefused",3,"2=Defused_The_Bomb")
}  
public BombPlantComplete(){
     BombTimer = get_gametime()
     cooldown = BombTimer + 29.0 
}  
public BombDefused(){
         if(BombTimer >= cooldown)
         client_print(0,print_chat,"Message") 
}

Last edited by Wasc; 10-25-2011 at 16:28.
Wasc is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 10-25-2011 , 16:38   Re: Spread Values
Reply With Quote #4

At the top just declare both, don't assign any value here. new Float:variable
__________________

Last edited by Bugsy; 10-25-2011 at 16:42.
Bugsy is offline
Wasc
Junior Member
Join Date: Apr 2011
Old 10-26-2011 , 03:10   Re: Spread Values
Reply With Quote #5

Thanks Bugsy
Wasc is offline
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 14:22.


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