AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Spread Values (https://forums.alliedmods.net/showthread.php?t=170494)

Wasc 10-25-2011 14:10

Spread Values
 
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

Bugsy 10-25-2011 15:08

Re: Spread Values
 
define the 2 variables globally (above plugin_init, under includes), assign the values the same basically just remove "new Float:" from both.

Wasc 10-25-2011 16:25

Re: Spread Values
 
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")
}


Bugsy 10-25-2011 16:38

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

Wasc 10-26-2011 03:10

Re: Spread Values
 
Thanks Bugsy


All times are GMT -4. The time now is 14:22.

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