Raised This Month: $ Target: $400
 0% 

bool not working properly


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
xakintosh
I run no-steam servers!
Join Date: Feb 2010
Location: Edge of nowhere
Old 11-29-2010 , 10:29   bool not working properly
Reply With Quote #1

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
xakintosh is offline
Send a message via Yahoo to xakintosh Send a message via Skype™ to xakintosh
abdul-rehman
Veteran Member
Join Date: Jan 2010
Location: Khi, Pakistan
Old 11-29-2010 , 10:41   Re: bool not working properly
Reply With Quote #2

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 }
__________________

My Plugins For ZP

Inactive due to College and Studies
abdul-rehman is offline
Send a message via Yahoo to abdul-rehman Send a message via Skype™ to abdul-rehman
xakintosh
I run no-steam servers!
Join Date: Feb 2010
Location: Edge of nowhere
Old 11-29-2010 , 11:25   Re: bool not working properly
Reply With Quote #3

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)
xakintosh is offline
Send a message via Yahoo to xakintosh Send a message via Skype™ to xakintosh
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 11-29-2010 , 11:32   Re: bool not working properly
Reply With Quote #4

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...
__________________
- tired and retired -

- my plugins -
ConnorMcLeod is offline
xakintosh
I run no-steam servers!
Join Date: Feb 2010
Location: Edge of nowhere
Old 11-29-2010 , 11:34   Re: bool not working properly
Reply With Quote #5

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*/ }
xakintosh is offline
Send a message via Yahoo to xakintosh Send a message via Skype™ to xakintosh
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 11-29-2010 , 11:39   Re: bool not working properly
Reply With Quote #6

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

__________________
- tired and retired -

- my plugins -

Last edited by ConnorMcLeod; 11-29-2010 at 11:42.
ConnorMcLeod is offline
abdul-rehman
Veteran Member
Join Date: Jan 2010
Location: Khi, Pakistan
Old 11-29-2010 , 12:34   Re: bool not working properly
Reply With Quote #7

PLZ post ur whole code
__________________

My Plugins For ZP

Inactive due to College and Studies
abdul-rehman is offline
Send a message via Yahoo to abdul-rehman Send a message via Skype™ to abdul-rehman
xakintosh
I run no-steam servers!
Join Date: Feb 2010
Location: Edge of nowhere
Old 11-29-2010 , 13:42   Re: bool not working properly
Reply With Quote #8

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 }

Last edited by xakintosh; 11-29-2010 at 16:24. Reason: Real Code
xakintosh is offline
Send a message via Yahoo to xakintosh Send a message via Skype™ to xakintosh
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 11:25.


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