AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Catching 10sec beginning of the round (https://forums.alliedmods.net/showthread.php?t=107308)

KadiR 10-25-2009 05:47

Catching 10sec beginning of the round
 
I want to add an option, that if player type '' hi '' , cmdSayHI opens, but only if max 10sec, so:

Round starts, I type '' hi '' cmdSayHI begins, but if 10seconds are passed in the round and I try to type '' hi '' it says in chat to the user: 10 seconds already passed!

It should be this function with this '' 10 seconds '' option.

PHP Code:

register_clcmd("say HI""cmdSayHI"); 


One 10-25-2009 07:23

Re: Catching 10sec beginning of the round
 
you could get the time @ start round + mp_freezetime - gametime = the_diffrent

if the_diffrent > 10 , then block the say cmd. but i dont know how you can block the say cmd .

Sylwester 10-25-2009 08:18

Re: Catching 10sec beginning of the round
 
here some code:
PHP Code:

#include <amxmodx>
#include <hamsandwich>

new g_user_time[33]

public 
plugin_init(){
    
RegisterHam(Ham_Spawn"player""player_spawn"1)
    
register_clcmd("say hi""cmdSayHI")
}

public 
client_connect(id)
    
g_user_time[id] = 0
    
public player_spawn(id)
    if(
is_user_alive(id) && g_user_time[id] <= 0)
        
g_user_time[id] = get_systime()

public 
cmdSayHI(id){
    if(
g_user_time[id] <= 0){
        
//user has not been spawned yet since connect
        
return PLUGIN_CONTINUE
    
}
    if(
get_systime() - g_user_time[id] > 10){
        
//at least 10 seconds passed since user first spawn
        
client_print(idprint_chat"10 seconds already passed.")
        return 
PLUGIN_HANDLED
    
}

    
//user has been spawned and 10 seconds have not passed yet

    
return PLUGIN_CONTINUE



KadiR 03-19-2010 19:07

Re: Catching 10sec beginning of the round
 
Tried and I think it isn't that what I wanted.

PHP Code:

//at least 10 seconds passed since user first spawn 

Well I want it, everytime if the round, so at least 10 seconds passed since user spawned in a round.

Seta00 03-19-2010 19:11

Re: Catching 10sec beginning of the round
 
PHP Code:

#include <amxmodx>

new bool:tenSecs;

public 
plugin_init() {
    
register_clcmd("say hi""cmdSayHi");
    
register_logevent("logevent_RoundStart"2"1=Round_Start");
}

public 
logevent_RoundStart() {
    
tenSecs false;
    
set_task(10.0"tenSecsPassed");
}

public 
tenSecsPassed() {
    
tenSecs true;
}

public 
cmdSayHi(id) {
    if (
tenSecs) {
        
client_print(idprint_chat"10 seconds already passed.");
        return 
PLUGIN_HANDLED;
    }
    
    
// your code goes here
    
    
return PLUGIN_HANDLED;




All times are GMT -4. The time now is 17:32.

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