AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   start from 001 (https://forums.alliedmods.net/showthread.php?t=93060)

biscuit628 05-23-2009 19:31

start from 001
 
hi i need a little bit help,
how to start up with "001"?
becoz of some reason,i cannot use "1"
PHP Code:

    new Apple 000

public something(id)
{
    
Apple++
    
client_print(0,print_chat,"%d",Apple)
    
set_task(3.0,"something")



shine771 05-23-2009 19:52

Re: start from 001
 
PHP Code:

new Cherry

public GimmeCherry() {
    
    new 
sCherry[4]
    
    
Cherry++
    
    
formatex(sCherry,3,"%s%s%d",Cherry 100 "0" ""Cherry 10 "0" "",Cherry)
    
    
client_print(0,print_chat,"%s",sCherry)



Exolent[jNr] 05-23-2009 23:29

Re: start from 001
 
Quote:

Originally Posted by shine771 (Post 833375)
PHP Code:

new Cherry

public GimmeCherry() {
    
    new 
sCherry[4]
    
    
Cherry++
    
    
formatex(sCherry,3,"%s%s%d",Cherry 100 "0" ""Cherry 10 "0" "",Cherry)
    
    
client_print(0,print_chat,"%s",sCherry)



WOW! Just do this:
PHP Code:

new Cherry

public GimmeCherry() {
    
    
Cherry++
    
    
client_print(0,print_chat,"%03i",Cherry)


%3i means an integer with 3 character spaces used. If the number is 2 or less digits, it will fill the rest with spaces.
%03i means that the spaces to fill the emptiness will be 0's instead.

biscuit628 05-24-2009 04:38

Re: start from 001
 
thank you shine and Exolent

shine771 05-24-2009 05:49

Re: start from 001
 
Thanks exolent.
You learn new things everyday, no matter how long have you coded.


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

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