Raised This Month: $12 Target: $400
 3% 

Best Player MOTD


Post New Thread Reply   
 
Thread Tools Display Modes
Natsheh
Veteran Member
Join Date: Sep 2012
Old 10-19-2017 , 15:22   Re: Best Player MOTD
Reply With Quote #11

Quote:
Originally Posted by OciXCrom View Post
PHP Code:
new dot1 contain(szArg".") + 1;
for(new 
strlen(szArg) - 1dot1i--)
{
    if(
szArg[i] == '0')
        
szArg[i] = 0;
    else break

Any shorter way for doing it or a native I haven't noticed?
szArgs[i] = 0 and remove trim
__________________
@Jailbreak Main Mod v2.7.0 100%
@User Tag Prefix 100% done !
@Mystery Box 100% done !
@VIP System 100% done !


Last edited by Natsheh; 10-19-2017 at 16:11.
Natsheh is offline
Send a message via MSN to Natsheh Send a message via Skype™ to Natsheh
klippy
AlliedModders Donor
Join Date: May 2013
Location: Serbia
Old 10-19-2017 , 17:04   Re: Best Player MOTD
Reply With Quote #12

I'd probably do it like this:
PHP Code:
// This may error if there isn't a '.' or there aren't any characters after the '.' character. Make sure these conditions are met (formatting with %.2f should guarantee it I guess).
new index strlen(szArg) - 1;
while(
szArgs[index] == '0' && szArgs[index 1] != '.') { --index; }
szArgs[index 1] = EOS

Last edited by klippy; 10-20-2017 at 09:49.
klippy is offline
Natsheh
Veteran Member
Join Date: Sep 2012
Old 10-19-2017 , 23:07   Re: Best Player MOTD
Reply With Quote #13

Quote:
Originally Posted by KliPPy View Post
I'd probably do it like this:
PHP Code:
new index strlen(szArg) - 1;
while(
szArgs[index] == '0') { --index; }
szArgs[index] = EOS
What if the string was 1.0000000000 will result >> 1.
__________________
@Jailbreak Main Mod v2.7.0 100%
@User Tag Prefix 100% done !
@Mystery Box 100% done !
@VIP System 100% done !

Natsheh is offline
Send a message via MSN to Natsheh Send a message via Skype™ to Natsheh
klippy
AlliedModders Donor
Join Date: May 2013
Location: Serbia
Old 10-20-2017 , 04:22   Re: Best Player MOTD
Reply With Quote #14

Quote:
Originally Posted by Natsheh View Post
What if the string was 1.0000000000 will result >> 1.
Good catch. Edited.
klippy is offline
OciXCrom
Veteran Member
Join Date: Oct 2013
Location: Macedonia
Old 10-20-2017 , 08:49   Re: Best Player MOTD
Reply With Quote #15

This resulted in "0." - changing the last line to szArgs[index + 1] fixed it. Thanks.
__________________
OciXCrom is offline
Send a message via Skype™ to OciXCrom
klippy
AlliedModders Donor
Join Date: May 2013
Location: Serbia
Old 10-20-2017 , 09:51   Re: Best Player MOTD
Reply With Quote #16

Quote:
Originally Posted by OciXCrom View Post
This resulted in "0." - changing the last line to szArgs[index + 1] fixed it. Thanks.
Right, forgot to edit that in too. Just thought about it and wrote it down quickly, didn't test the approach, just wanted to give you an idea. At least you got it working.
klippy is offline
Natsheh
Veteran Member
Join Date: Sep 2012
Old 10-20-2017 , 10:01   Re: Best Player MOTD
Reply With Quote #17

Quote:
Originally Posted by KliPPy View Post
Right, forgot to edit that in too. Just thought about it and wrote it down quickly, didn't test the approach, just wanted to give you an idea. At least you got it working.
PHP Code:
new index strlen(szArgs) - 1;
while(
szArgs[index] == '0' && szArgs[index 1] != '.') { szArgs[index] = EOS; --index; } 
You didnt entererd it into the body of the loop...
Also why complicate things and add +1 you can just put it before the subtraction...
__________________
@Jailbreak Main Mod v2.7.0 100%
@User Tag Prefix 100% done !
@Mystery Box 100% done !
@VIP System 100% done !

Natsheh is offline
Send a message via MSN to Natsheh Send a message via Skype™ to Natsheh
OciXCrom
Veteran Member
Join Date: Oct 2013
Location: Macedonia
Old 10-20-2017 , 10:09   Re: Best Player MOTD
Reply With Quote #18

Setting one character in a string to EOS will remove all characters after that one, so putting it in the loop is unnecessary. The loop is just there to find out on which position in the string the EOS should be put.
__________________
OciXCrom is offline
Send a message via Skype™ to OciXCrom
Natsheh
Veteran Member
Join Date: Sep 2012
Old 10-20-2017 , 10:16   Re: Best Player MOTD
Reply With Quote #19

Quote:
Originally Posted by OciXCrom View Post
Setting one character in a string to EOS will remove all characters after that one, so putting it in the loop is unnecessary. The loop is just there to find out on which position in the string the EOS should be put.
I just thought it will remove the char and proceeds printing the characters


Thanks for the info..
__________________
@Jailbreak Main Mod v2.7.0 100%
@User Tag Prefix 100% done !
@Mystery Box 100% done !
@VIP System 100% done !


Last edited by Natsheh; 10-20-2017 at 10:17.
Natsheh is offline
Send a message via MSN to Natsheh Send a message via Skype™ to Natsheh
OciXCrom
Veteran Member
Join Date: Oct 2013
Location: Macedonia
Old 10-20-2017 , 12:25   Re: Best Player MOTD
Reply With Quote #20

To clarify, EOS means "end of string", so it basically makes the character the end of that string.
__________________

Last edited by OciXCrom; 10-20-2017 at 12:26.
OciXCrom is offline
Send a message via Skype™ to OciXCrom
Reply


Thread Tools
Display Modes

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 08:44.


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