How to parse string
Hey, I would like to parse string with 3 and 4 parameters, and just ignore quotes
My string is like !mute player time reason as it should work if I write something like: Quote:
How to get reason should be something like, get whole text, and then just replace !mute, player, time with empty string. |
Re: How to parse string
you can use strbreak:
1. replace "!mute " with "" 2. break the string to "player", "time reason", so you have the player 3. break the 2. string ("time reason") to "time", "reason" |
Re: How to parse string
Can you show me example please ? I'm very begginer in scripting.
Is it something like this? PHP Code:
|
Re: How to parse string
Quote:
string.inc: PHP Code:
|
Re: How to parse string
Or you can use parse()
|
Re: How to parse string
This is how I would 'parse' the string:
PHP Code:
Quote:
|
Re: How to parse string
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:
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:
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:
|
Re: How to parse string
You were very close.
PHP Code:
|
Re: How to parse string
OK thanks, it works perfect, But how can I display player the time when it expires or something like :
mute time left: %d, But I would like to show him something like: mute time left: %dMinutes %dSeconds. if mute time is less than minute then show only seconds, and if mute time is more than 60 minutes then also show %dHours. help please :) It would be cool if it would say something like: of if there are 0 days then: |
Re: How to parse string
PHP Code:
Quote:
OR an alternative: PHP Code:
|
| All times are GMT -4. The time now is 04:20. |
Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.