SA-MP Forums Archive
[Tutorial] How to create space with one string or Spacing Strings. (sscanf) - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Tutorials (https://sampforum.blast.hk/forumdisplay.php?fid=70)
+---- Thread: [Tutorial] How to create space with one string or Spacing Strings. (sscanf) (/showthread.php?tid=243436)



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
View Post
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
View Post
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
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.


Re: How to create space with one string or Spacing Strings. (sscanf) - =WoR=Varth - 10.09.2011

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.