AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   bool not working properly (https://forums.alliedmods.net/showthread.php?t=144140)

xakintosh 11-29-2010 10:29

bool not working properly
 
I have this bool
Code:
bool:CheckPlayer( const id ) {     new Float:flGametime = get_gametime()       if( g_flLastCmd[ id ] < flGametime ) {         g_flLastCmd[ id ] = flGametime + 1.00         return false     }     if(!is_user_alive(id)) {         ColorChat(id, RED, "[kz#] ^x01You must be alive to use this command...")     } else { /*nothing*/ }     return true }
And i check all of my commands with it but not working properly, can you help me.
I Want dead peoples dont have acess to commands and if they are alive to work, and also have anti-spam function

abdul-rehman 11-29-2010 10:41

Re: bool not working properly
 
Try this:
Code:
bool:CheckPlayer( const id ) {     new Float:flGametime = get_gametime( )       if ( g_flLastCmd[ id ] < flGametime )     {         g_flLastCmd[ id ] = flGametime + 1.00         return false     }     if (!is_user_alive(id))     {         ColorChat(id, RED, "[kz#] ^x01You must be alive to use this command...")         return false     }     return true }

xakintosh 11-29-2010 11:25

Re: bool not working properly
 
It's working but not i don't wanna dead people to use commdans -- picture (and spam block don't work on dead people :( )

I also get this error , but i need only to check if player connected. (i think so)
Code:
L 11/29/2010 - 18:16:55: [AMXX] Displaying debug trace (plugin "kz_plugin.amxx") L 11/29/2010 - 18:16:55: [AMXX] Run time error 4: index out of bounds L 11/29/2010 - 18:16:55: [AMXX]    [0] kz_plugin.sma::CheckPlayer (line 146) L 11/29/2010 - 18:16:55: [AMXX]    [1] kz_plugin.sma::fwdUse (line 218)

ConnorMcLeod 11-29-2010 11:32

Re: bool not working properly
 
I'm using this in plugin of mine :
PHP Code:

bool:bCheckFlood(idFloat:flDelay 1.0)
{
    static 
Float:flTime
    flTime 
get_gametime()

    if(
g_flNextCmd[id] > flTime)
    {
        return 
true
    
}

    
g_flNextCmd[id] = flTime flDelay
    
return false


Also, your error is because you pass an id > 32, aka not a player...

xakintosh 11-29-2010 11:34

Re: bool not working properly
 
Can it be combie with this
Code:
if(!is_user_alive(id)) {         ColorChat(id, RED, "[kz#] ^x01You must be alive to use this command...")         return PLUGIN_HANDLED     } else { /*alive*/ }

ConnorMcLeod 11-29-2010 11:39

Re: bool not working properly
 
PHP Code:

bool:CheckPlayer(idFloat:flDelay 1.0bool:bHasToBeAlive true)
{
    if( 
bHasToBeAlive && !is_user_alive(id) )
    { 
        
ColorChat(idRED"[kz#] ^x01You must be alive to use this command...")
        return 
false
    
}

    new 
Float:flTime get_gametime()
    new 
Float:flDifference flTime g_flNextCmd[id]

    if(
flDifference 0)
    {
        
ColorChat(idRED"[kz#] ^x01You have to wait %.1s to use this command..."flDifference)
        return 
false
    
}

    
g_flNextCmd[id] = flTime flDelay

    
return true



abdul-rehman 11-29-2010 12:34

Re: bool not working properly
 
PLZ post ur whole code

xakintosh 11-29-2010 13:42

Re: bool not working properly
 
i remove bypass this function easy with this
Code:
bool:CheckSpam(const id) {     new Float:flGametime = get_gametime()       if(is_user_connected(id)) { // some fix for sv_restartround 1         if(g_flLastCmd[id]  < flGametime) {             g_flLastCmd[id] = flGametime + 1.00             return false         }     }     return true } public CheckPlayer(id) {     if(!is_user_alive(id)) {         ColorChat(id, RED, "[kz#] ^x01You must be alive to use this command...")         return PLUGIN_HANDLED // Block cmd's for non-alive players somehow xD         } else {         /*nothing i think this plugin continue next func ??*/     }     return PLUGIN_CONTINUE }


All times are GMT -4. The time now is 11:25.

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