[Tutorial] How to create space with one string or Spacing Strings. (sscanf)
#1

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.
Reply
#2

Looks great.
Reply
#3

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 )
Reply
#4

really, I don't now for what use is this??
Reply
#5

pawn Code:
sscanf("hello\\ there 27", "s[32]i", str, val);
Reply
#6

Quote:
Originally Posted by varthshenon
View Post
pawn Code:
sscanf("hello\\ there 27", "s[32]i", str, val);
And how do you use that in your commands? Do explain.
Reply
#7

Quote:
Originally Posted by PrawkC
View Post
And how do you use that in your commands? Do explain.
/t hello\\ there 27 {enter}
Reply
#8

Quote:
Originally Posted by varthshenon
View Post
/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.
Reply
#9

Quote:
Originally Posted by PrawkC
View Post
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.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)