SA-MP Forums Archive
Giving gap in Ban Reason. - 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)
+--- Thread: Giving gap in Ban Reason. (/showthread.php?tid=594708)



Giving gap in Ban Reason. - SpikY_ - 22.11.2015

As title says, I don't have much knowledge about sscanf, So how can i give Space/or Gap between the Reason i mean like " Reason: Fuck Off "; I want to give reason like this, but when i type it, nothing works and when i type " Reason: FuckOff "; it works. Here are the codes:

Код:
	new target, reason[35], days;
	if(sscanf(params, "is[35]I(0)", target, reason, days)) return SendClientMessage(playerid, COLOR_THISTLE, "{FF0000}» USAGE: {FFFFFF}/Ban (PlayerID) (Reason) (Days=Use this to Temp ban otherwise leave it)");



Re: Giving gap in Ban Reason. - ReD_HunTeR - 22.11.2015

PHP код:
    new targetreason[35], days;
    if(
sscanf(params,"uD(0)S(NoReason)[35]",target,days,reason)) return SendClientMessage(playeridCOLOR_THISTLE"{FF0000}» USAGE: {FFFFFF}/Ban (PlayerID) (Days=Use this to Temp ban otherwise leave it) (Reason)"); 
try this,
Syntax: /ban (playerid) (days) (reason)


Re: Giving gap in Ban Reason. - Private200 - 22.11.2015

I suggest you to always use string at the end so you can use space between your reason (/ban [playerid] [days] [reason] - reason: fuck off). Before the syntax would be just FuckOff, else it would count the 'off' as part of the days.

I hope it makes you understand what's wrong in your code. Red_Hunter has posted the right code for you though, I'm just explaining as you said that you were newbie.


Re: Giving gap in Ban Reason. - SpikY_ - 22.11.2015

Код:
    new target, reason[35], days;
    if(sscanf(params,"uD(0)S(NoReason)[35]",target,days,reason)) return SendClientMessage(playerid, COLOR_THISTLE, "{FF0000}» USAGE: {FFFFFF}/Ban (PlayerID) (Days=Use this to Temp ban otherwise leave it) (Reason)");
The Sentence i have bold is optional, whether i put days amount or not. But this time i don't want to put number of days, If i type Reason with gap then it consider to first letter as Days which will not access.

and it cause the same issue still.


Re: Giving gap in Ban Reason. - Vince - 22.11.2015

If you have a string with spaces in the middle sscanf does not know where to split anymore and as a result you get this behavior.

If params is this:
Код:
0 my very long reason 7
and if sscanf expects 3 parameters then it will be split like this:
Код:
[0] [my] [very long reason 7]
As far as I know there is no workaround.