SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help

Reply
 
Thread Tools Display Modes
Old 03/02/2020, 11:25 AM   #1
redtin06
Little Clucker
 
Join Date: Oct 2018
Location: maharlika
Posts: 44
Reputation: 0
Default string / integer

if something == 0;
something = "None";

then if there is a value == 1 (example)
format(coordsstring, sizeof(coordsstring),"Something: %d", something);
"Something: 1"

if the value is back to 0
"Something: None"

if u get me can u help me
redtin06 is offline   Reply With Quote
Old 03/02/2020, 11:30 AM   #2
OsmanMalagic
Little Clucker
 
Join Date: Jul 2016
Location: EX-YU
Posts: 40
Reputation: 51
Default Re: string / integer

Quote:
Originally Posted by redtin06 View Post
if something == 0;
something = "None";

then if there is a value == 1 (example)
format(coordsstring, sizeof(coordsstring),"Something: %d", something);
"Something: 1"

if the value is back to 0
"Something: None"

if u get me can u help me
I don't understand what do you mean, you want string to integer or vice versa?
OsmanMalagic is offline   Reply With Quote
Old 03/02/2020, 11:36 AM   #3
redtin06
Little Clucker
 
Join Date: Oct 2018
Location: maharlika
Posts: 44
Reputation: 0
Default Re: string / integer

Quote:
Originally Posted by OsmanMalagic View Post
I don't understand what do you mean, you want string to integer or vice versa?
example

if my integer value is == 0
my output will be "None" in format will be "My Integer: %d", myInteger);
Output:
My Integer: None

and if there is a value example == 1
My Integer: 1

sorry for bad explanation i hope u get it
redtin06 is offline   Reply With Quote
Old 03/02/2020, 11:48 AM   #4
Beckett
High-roller
 
Beckett's Avatar
 
Join Date: Feb 2012
Location: www.finalnights-rp.com
Posts: 1,794
Reputation: 104
Default Re: string / integer

PHP Code:
new string[4];
if(
variable == 0)
    
string "No";
else 
string "Yes"
Think simple.
__________________
Final Nights Roleplay
The first SA-MP server that is not regulated by administrators.
No OOC hierarchy. Strictly directed by players. Utopian vision.

El primer servidor SA-MP que no está regulado por los administradores.
Sin jerarquías OOC. Estrictamente dirigido por jugadores. Visión utópica.

Primul server de SA-MP care nu este regulat de administratori.
Fără ierarhie OOC. Strict dictat de jucători. Visiune utopică.

Yöneticiler tarafından düzenlenmeyen ilk SA-MP sunucusu.
OOC hiyerarşisi yok. Kesinlikle oyuncular tarafından yönetiliyor. Ütopik görme.


Become a Member of our Discord Channel
Beckett is offline   Reply With Quote
Old 03/02/2020, 11:51 AM   #5
redtin06
Little Clucker
 
Join Date: Oct 2018
Location: maharlika
Posts: 44
Reputation: 0
Default Re: string / integer

Quote:
Originally Posted by Beckett View Post
PHP Code:
new string[4];
if(
variable == 0)
    
string "No";
else 
string "Yes"
Think simple.
what if

if(variable == 0)
string = "No";
else string = "%d", myInteger;

how is it?
redtin06 is offline   Reply With Quote
Old 03/02/2020, 11:55 AM   #6
OsmanMalagic
Little Clucker
 
Join Date: Jul 2016
Location: EX-YU
Posts: 40
Reputation: 51
Default Re: string / integer

Quote:
Originally Posted by redtin06 View Post
example

if my integer value is == 0
my output will be "None" in format will be "My Integer: %d", myInteger);
Output:
My Integer: None

and if there is a value example == 1
My Integer: 1

sorry for bad explanation i hope u get it
Do you speak for this:

PHP Code:
new Number;
new 
string[128];

if(
Number == 0)
{
    
format(stringsizeof(string), "Number is none");
    
SCM(playerid, -1string);
}
else if(
Number == 1)
{
    
format(stringsizeof(string), "Number is One");
    
SCM(playerid, -1string);
}
// If the Number is Bigger than 1
else if(Number 1)
{
    
format(stringsizeof(string), "Number is %d"Number);
    
SCM(playerid, -1string);

OsmanMalagic is offline   Reply With Quote
Old 03/02/2020, 12:35 PM   #7
Beckett
High-roller
 
Beckett's Avatar
 
Join Date: Feb 2012
Location: www.finalnights-rp.com
Posts: 1,794
Reputation: 104
Default Re: string / integer

Quote:
Originally Posted by redtin06 View Post
what if

if(variable == 0)
string = "No";
else string = "%d", myInteger;

how is it?
PHP Code:
if(variable == 0)
    
string "No";
else 
format(stringsizeof string"%d"variable); 
__________________
Final Nights Roleplay
The first SA-MP server that is not regulated by administrators.
No OOC hierarchy. Strictly directed by players. Utopian vision.

El primer servidor SA-MP que no está regulado por los administradores.
Sin jerarquías OOC. Estrictamente dirigido por jugadores. Visión utópica.

Primul server de SA-MP care nu este regulat de administratori.
Fără ierarhie OOC. Strict dictat de jucători. Visiune utopică.

Yöneticiler tarafından düzenlenmeyen ilk SA-MP sunucusu.
OOC hiyerarşisi yok. Kesinlikle oyuncular tarafından yönetiliyor. Ütopik görme.


Become a Member of our Discord Channel
Beckett is offline   Reply With Quote
Old 03/02/2020, 12:39 PM   #8
Hassel
Little Clucker
 
Join Date: Dec 2019
Posts: 35
Reputation: 12
Default Re: string / integer

pawn Code:
new str[11];

strcat(((something[0] = EOS), something), !variable ? "None" : (format(str, sizeof(str), "%i", variable), str));
Hassel is offline   Reply With Quote
Old 03/02/2020, 03:40 PM   #9
Sasinosoft
Little Clucker
 
Sasinosoft's Avatar
 
Join Date: Jan 2020
Location: Tampa, FL
Posts: 26
Reputation: 1
Default Re: string / integer

Quote:
Originally Posted by Hassel View Post
pawn Code:
new str[11];

strcat(((something[0] = EOS), something), !variable ? "None" : (format(str, sizeof(str), "%i", variable), str));
Lmao, best way to scare a newbie away
Sasinosoft is offline   Reply With Quote
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


Similar Threads
Thread Thread Starter Forum Replies Last Post
[Ajuda] Login, string, integer MkeY Português/Portuguese 4 20/06/2016 05:28 PM
string or integer? Don_Cage Scripting Help 5 05/02/2014 01:58 PM
Integer to a string. vIBIENNYx Scripting Help 5 18/06/2012 06:03 PM
String to Integer spd_sahil Scripting Help 3 19/10/2011 07:23 PM
Are IP's an integer or string? Celson Help Archive 1 27/07/2009 07:19 AM


All times are GMT. The time now is 06:12 AM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.