How to create space with one string or Spacing Strings. (sscanf) -
Tee - 23.03.2011
Hey Guys, I have seen where people wanted to use spaces in strings even I had this problem. I experimented with sscanf and found out how to do it.
It is simple. Just put the "s" last. Done. Just joking.
Here is how. You have a command that creates houses or businesses. Example:
pawn Code:
if(sscanf(params,"siii",busid,cost,payout,name))return SendClientMessage(playerid, 0xFF0000AA, "Usage: /createbus [name] [cost] [payout] [businessid]");
But when you type it, you have to join the words. Example if you want Clucklin Bell you would have to type Clucklin_Bell with the "underscore".
Example:
If you look at the command above, you will see that it only has space for 1 string. Just Clucklin or Clucklin_Bell because the 2nd thing you will type it will go over into the integers.
Now when you use the command with the string at the end. Exampe:
pawn Code:
if(sscanf(params,"iiis",busid,cost,payout,name))return SendClientMessage(playerid, 0xFF0000AA, "Usage: /createbus [businessid] [cost] [payout] [name]");
Example:
If you look at the 1st picture you will see that i have "Tutorial_Test_1" and the 2nd picture I have "Tutorial <space> Test <space> 2"
Because I placed the string first in the 1st pic and last in the 2nd pic.
:createbus [name] [cost] [payout] [businessid]
(This is just a test command) Here a sting would be used for the name. When the string is 1st you will not be able to use spaces.
:createbus [businessid] [cost] [payout] [name]
If you look here, you will see that he string is last.
Thanks for having me.
I hope this helped.
Re: How to create space with one string or Spacing Strings. (sscanf) -
Davz*|*Criss - 10.09.2011
Looks great.
Re: How to create space with one string or Spacing Strings. (sscanf) -
Retardedwolf - 10.09.2011
An improvement could be adding the stringsize. If not included, it will give an error in the console.
Example :
pawn Code:
if ( sscanf( params, "s[STRING_LENGTH]", string )
Re: How to create space with one string or Spacing Strings. (sscanf) -
System64 - 10.09.2011
really, I don't now for what use is this??
Re: How to create space with one string or Spacing Strings. (sscanf) -
=WoR=Varth - 10.09.2011
pawn Code:
sscanf("hello\\ there 27", "s[32]i", str, val);
Re: How to create space with one string or Spacing Strings. (sscanf) -
PrawkC - 10.09.2011
Quote:
Originally Posted by varthshenon
pawn Code:
sscanf("hello\\ there 27", "s[32]i", str, val);
|
And how do you use that in your commands? Do explain.
Re: How to create space with one string or Spacing Strings. (sscanf) -
=WoR=Varth - 10.09.2011
Quote:
Originally Posted by PrawkC
And how do you use that in your commands? Do explain.
|
/t hello\\ there 27 {enter}
Re: How to create space with one string or Spacing Strings. (sscanf) -
PrawkC - 10.09.2011
Quote:
Originally Posted by varthshenon
/t hello\\ there 27 {enter}
|
oh, well that'd be stupid.. you can of course use a delimiter also, but that isnt the point of what hes trying to do with the tut.
Re: How to create space with one string or Spacing Strings. (sscanf) -
=WoR=Varth - 10.09.2011
Quote:
Originally Posted by PrawkC
oh, well that'd be stupid.. you can of course use a delimiter also, but that isnt the point of what hes trying to do with the tut.
|
The title says "How to create space with one string or Spacing Strings. (sscanf)". So I tell him what I know. Don;t blame me.