AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   A little problem. Can you help me? (https://forums.alliedmods.net/showthread.php?t=130299)

mottzi 06-22-2010 13:43

A little problem. Can you help me?
 
Hello.

When the player sais "pack" then a BarTime shows. After it loads the player get 50 HP...

But all this just then the bool:limited is true.

Thats not the problem; it works very fine but the bool ist just for 1 player...

When another player is there just 1 can use the BarTime. You udnerstand.

So i need 32 bools, 1 for every id.

my code:


PHP Code:

#include <amxmodx>
#include <amxmisc>
#include <fun>


new bartime1;
new 
bool:limited true;           //  <--- HERE <---------------------------------------------------------
 
public plugin_init()
{
    
bartime1 get_user_msgid("BarTime");
    
register_event"HLTV""roundstart1""a""1=0""2=0" )
    
register_clcmd("say pack","show_bar1")
}

public 
show_bar1(id)
{
    
    if(
limited == true
    {
        
set_user_rendering(id,kRenderFxGlowShell,255,0,0,kRenderNormal,25)
        
message_begin(MSG_ONE,bartime1, {0,0,0} ,id);
        
write_short(10);
        
message_end();
        
set_task(9.5"after_bar1"id)
    }
    else
    {
        
client_print(idprint_chat"[HP] You already used ur healthpack! Nextround, you can use a new one.")
    }

}

public 
roundstart1(id)
{
    
limited true;
}

public 
after_bar1(id)
{

        
set_user_rendering(id,kRenderFxGlowShell,0,0,0,kRenderNormal,25
        
set_user_health(idget_user_health(id) + 40)
        
limited false;



abdul-rehman 06-22-2010 14:03

Re: A little problem. Can you help me?
 
You dont need to put the bool: tag when creating a boolean variable bcoz it is not considered necessary...:)

mottzi 06-22-2010 14:05

Re: A little problem. Can you help me?
 
yeah, but the problem is, that every id needs an own variable but i dont know how :(

RedRobster 06-22-2010 14:06

Re: A little problem. Can you help me?
 
Do
PHP Code:

new bool:limited[33

Then, in after bar 1, when you set it equal to false, do
PHP Code:

limited[id] = false 

And, in round start, loop through all of the players, and set the bool equal to false for every player. Also, it might be advised to set the bool equal to true if a player joins as well. Like, in the client_putinserver(id), set the bool equal to true just in case.

mottzi 06-22-2010 14:27

Re: A little problem. Can you help me?
 
Thanks i tried, but now it says "you already used" everytime i trz to use, but that cant be i never used it so limited[id] soudth be 1 -.-!

code:

PHP Code:

#include <amxmodx>
#include <amxmisc>
#include <fun>


new bartime1;
new 
bool:limited[33] = true;
 
public 
plugin_init()
{
    
bartime1 get_user_msgid("BarTime");
    
register_event"HLTV""roundstart1""a""1=0""2=0" )
    
register_clcmd("say pack","show_bar1")
}

public 
show_bar1(id)
{
    
    if(
limited[id] == true
    {
        
set_user_rendering(id,kRenderFxGlowShell,255,0,0,kRenderNormal,25)
        
message_begin(MSG_ONE,bartime1, {0,0,0} ,id);
        
write_short(10);
        
message_end();
        
set_task(9.5"after_bar1"id)
    }
    else
    {
        
client_print(idprint_chat"[HP] You already used ur healthpack! Nextround, you can use a new one.")
    }

}

public 
roundstart1(id)
{
    
  new 
players[32], pnumtempid;
  
get_players(playerspnum);

    
    for( new 
ii<pnumi++ )
    {
         
tempid players[i];
    
limited[tempid] = true;
    }
}

public 
after_bar1(id)
{

        
set_user_rendering(id,kRenderFxGlowShell,0,0,0,kRenderNormal,25
        
set_user_health(idget_user_health(id) + 40)
        
limited[id] = false;



RedRobster 06-22-2010 14:42

Re: A little problem. Can you help me?
 
If I remember correctly, doing:
PHP Code:

new bool:limited[33] = true

doesn't actually do anything, because all you are doing is setting limited[33] = true, not the rest of them.

mottzi 06-22-2010 14:46

Re: A little problem. Can you help me?
 
i tryd it without this true but dont works too

RedRobster 06-22-2010 15:34

Re: A little problem. Can you help me?
 
PHP Code:

#include <amxmodx>
#include <amxmisc>
#include <fun>

new bartime1;
new 
bool:limited[33];
 
public 
plugin_init()
{
 
bartime1 get_user_msgid("BarTime");
 
register_logevent"roundstart1"2"1=Round_Start")
 
register_clcmd("say pack","show_bar1")
}
public 
show_bar1(id)
{
    
 if(
limited[id] == true
 {
  
set_user_rendering(id,kRenderFxGlowShell,255,0,0,kRenderNormal,25)
  
message_begin(MSG_ONE,bartime1, {0,0,0} ,id);
  
write_short(10);
  
message_end();
  
set_task(9.5"after_bar1"id)
 }
 else
 {
  
client_print(idprint_chat"[HP] You already used ur healthpack! Nextround, you can use a new one.")
 }
}
public 
roundstart1(id)
{
    
 new 
players[32], pnumtempid;
 
get_players(playerspnum);
 for( new 
ii<pnumi++ )
 {
  
tempid players[i];
  
limited[tempid] = true;
 }
}
public 
after_bar1(id)
{
        
set_user_rendering(id,kRenderFxGlowShell,0,0,0,kRenderNormal,25
        
set_user_health(idget_user_health(id) + 40)
        
limited[id] = false;


Try that. I don't know why the event wasn't working, but I switched it for the logevent Round Start. See if that works.

mottzi 06-23-2010 05:15

Re: A little problem. Can you help me?
 
ye, it was the event... but i changed it to

RegisterHam(Ham_Spawn, "player", "FwdHamSpawn_Post", 1);

thats even bether cause the player gets an healthpack when he spawns :D

thank you much for ur time



mottzi


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

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