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

Code


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
jgtyui
Junior Member
Join Date: Jun 2010
Old 06-10-2013 , 06:15   Code
Reply With Quote #1

What is wrong with this code?
PHP Code:
stock FormatNumberNumberDelimiter[ ] ) {
 static 
bool:IsNegative Number true false;
 if( 
IsNegative ) {
  
Number absNumber );
 }
 static 
String32 ];
 
String num_to_strNumber );
 switch( String ) {
  case 
4:
  {
   
String] = Demiliter;
   break;
  }
  case 
5:
  {
   
String] = Demiliter;
   break;
  }
  case 
6:
  {
   
String] = Demiliter;
   break;
  }
  case 
7:
  {
   
String] = Demiliter;
   
String] = Demiliter;
   break;
  }
  case 
8:
  {
   
String] = Demiliter;
   
String] = Demiliter;
   break;
  }
  case 
9:
  {
   
String] = Demiliter;
   
String] = Demiliter;
   break;
  }
  case 
10:
  {
   
String] = Demiliter;
   
String] = Demiliter;
   
String] = Demiliter;
   break;
  }
 } 

I want to put a delimiter to players health to show insted of 4000 => 4,000 but i get a lot of errors.
jgtyui is offline
jimaway
Heeeere's Jimmy!
Join Date: Jan 2009
Location: Estonia
Old 06-10-2013 , 09:05   Re: Code
Reply With Quote #2

to answer your question: pretty much everything is wrong with that code, you're even using the num_to_str native wrong
jimaway is offline
jgtyui
Junior Member
Join Date: Jun 2010
Old 06-10-2013 , 09:16   Re: Code
Reply With Quote #3

Thanks for your answer and how i can make this code to work can you show me?
jgtyui is offline
.Dare Devil.
Veteran Member
Join Date: Sep 2010
Old 06-10-2013 , 11:44   Re: Code
Reply With Quote #4

PHP Code:
stock FormatNumberNumberDelimiter[ ] ) {
 static 
bool:IsNegative Number true false;
 if( 
IsNegative ) {
  
Number absNumber );
 }
 static 
String32 ];
 
String num_to_strNumber );
 
// fix for that
 // format( String, charsmax(String), "%d", Number )
 // or
 // num_to_str( Number ,String, charsmax(String)  )

 
switch( String ) {
  case 
4:
  {
   
String] = Demiliter;
   break;
  }
  case 
5:
  {
   
String] = Demiliter;
    
// Demiliter is an array so
    // String[ 2 ] = Demiliter[0] for example
   
break;
  }
  case 
6:
  {
   
String] = Demiliter;
   break;
  }
  case 
7:
  {
   
String] = Demiliter;
   
String] = Demiliter;
   break;
  }
  case 
8:
  {
   
String] = Demiliter;
   
String] = Demiliter;
   break;
  }
  case 
9:
  {
   
String] = Demiliter;
   
String] = Demiliter;
   break;
  }
  case 
10:
  {
   
String] = Demiliter;
   
String] = Demiliter;
   
String] = Demiliter;
   break; 
// why is this needed?
  
}
 } 


Last edited by .Dare Devil.; 06-10-2013 at 11:45.
.Dare Devil. is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 06-10-2013 , 23:03   Re: Code
Reply With Quote #5

Quote:
Originally Posted by jgtyui View Post
Thanks for your answer and how i can make this code to work can you show me?
The best way to go about this is to tell us what your end goal is. In english, explain what you want (no code).
__________________
fysiks is offline
claudiuhks
Yam Inside®™℠
Join Date: Jan 2010
Location: Living Randomly
Old 06-11-2013 , 03:25   Re: Code
Reply With Quote #6

Quote:
Originally Posted by jgtyui View Post
What is wrong with this code?
Almost everything. Just start another subject into Requests instead.
I suggest you to not set the title as Code.

Quote:
Originally Posted by fysiks View Post
The best way to go about this is to tell us what your end goal is. In english, explain what you want (no code).
Better if he would make a request.

Quote:
Originally Posted by .Dare Devil. View Post
PHP Code:
stock FormatNumberNumberDelimiter[ ] ) {
 static 
bool:IsNegative Number true false;
 if( 
IsNegative ) {
  
Number absNumber );
 }
 static 
String32 ];
 
String num_to_strNumber );
 
// fix for that
 // format( String, charsmax(String), "%d", Number )
 // or
 // num_to_str( Number ,String, charsmax(String)  )

 
switch( String ) {
  case 
4:
  {
   
String] = Demiliter;
   break;
  }
  case 
5:
  {
   
String] = Demiliter;
    
// Demiliter is an array so
    // String[ 2 ] = Demiliter[0] for example
   
break;
  }
  case 
6:
  {
   
String] = Demiliter;
   break;
  }
  case 
7:
  {
   
String] = Demiliter;
   
String] = Demiliter;
   break;
  }
  case 
8:
  {
   
String] = Demiliter;
   
String] = Demiliter;
   break;
  }
  case 
9:
  {
   
String] = Demiliter;
   
String] = Demiliter;
   break;
  }
  case 
10:
  {
   
String] = Demiliter;
   
String] = Demiliter;
   
String] = Demiliter;
   break; 
// why is this needed?
  
}
 } 

Do you even think about what are you writing?
How to switch variable String for cases?
__________________

Last edited by claudiuhks; 06-11-2013 at 03:30.
claudiuhks is offline
Send a message via MSN to claudiuhks Send a message via Yahoo to claudiuhks Send a message via Skype™ to claudiuhks
Clauu
Senior Member
Join Date: Feb 2008
Location: RO
Old 06-11-2013 , 05:32   Re: Code
Reply With Quote #7

PHP Code:
public plugin_init() {
    
    new 
data[32],hp=1000;
    
format_number(hp,',',data,charsmax(data));
    
server_print(data); // 1,000
}

stock format_number(nr,delim,data[],len) {

    
num_to_str(nr,data,len);
    new 
strlen(data);
    if(
c<4||c>9)
        return;
       
    new 
tmp1[32],tmp2[32];
    if(
c<7) {
        
strmid(data,tmp1,0,c-3);
        
format(data,len,"%s%c%s",tmp1,delim,data[c-3]);
    }   
    else {
        
strmid(data,tmp1,0,c-6);
        
strmid(data,tmp2,c-6,c-3);
        
format(data,len,"%s%c%s%c%s",tmp1,delim,tmp2,delim,data[strlen(tmp1)+3]);
    }   
}

stock strmid(const source[],dest[],start,end) {
    new 
i;
    for(
i=start;i<end;i++)
        
dest[i-start] = source[i];
    
dest[i] = EOS;


Last edited by Clauu; 06-11-2013 at 05:45.
Clauu is offline
.Dare Devil.
Veteran Member
Join Date: Sep 2010
Old 06-11-2013 , 06:26   Re: Code
Reply With Quote #8

Quote:
Originally Posted by claudiuhks View Post


Do you even think about what are you writing?
How to switch variable String for cases?
i did not noticed that.
.Dare Devil. is offline
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 09:26.


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