Raised This Month: $ Target: $400
 0% 

How to parse string


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
monolit
Junior Member
Join Date: May 2011
Old 05-14-2011 , 04:12   Re: How to parse string
Reply With Quote #9

Thanks it works, also remove_quotes needed.

One more question, how to check is there a string character in szTime ?
is it correct: ?

PHP Code:
new bantime;
        
        if(
containi(szTime"m") != -1)
        {
            
bantime str_to_num(szTime) * 60;
        }else if(
containi(szTime"h") != -1)
        {
            
bantime str_to_num(szTime) * 60 60;
        }else if(
containi(szTime"d") != -1)
        {
            
bantime str_to_num(szTime) * 60 60 24;
        } 
I would like to make that if player writes 1m in bantime, the bantime would be 60seconds

if 1h then the player would be banned for 1 hour.
if 1d then the player would be banned for 1 day.

and then check if bantime exceeds the limit (7 days is max)
PHP Code:
if(bantime 604800)
        {
            
client_print_color(idDontChange"^4[ INFO ]^1 ban_time can not exceed more than 7 days")
            return 
PLUGIN_HANDLED_MAIN;
        } 
It should auto convert to seconds then I'm going to use get_systime() + bantime.

So am I doing it correctly ?

Why this is not working ?:

I set user mute time with this:
[php]
mutetime = str_to_num(szTime) * 60 * 60;
iMute[player] = get_systime() + mutetime;

format(szTemp,charsmax(szTemp),"INSERT INTO `bans` ( `ip` , `mute_time`, `mute_reason`, `mute_admin`)VALUES ('%s','%d', '%s', '%s');", szTargetIp, get_systime() + mutetime, szReason, szAdminName)
[php]

and on say event I check this:
PHP Code:
if(get_systime() + iMute[id] > get_systime())
    {
        
client_print_color(idDontChange"^4[ INFO ]^1 You can not chat while you are mutted")
        return 
PLUGIN_HANDLED;
    } 
But user still can chat even if his mute time is higher than systime.

Last edited by monolit; 05-14-2011 at 05:00.
monolit is offline
 



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 04:20.


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