SA-MP Forums Archive
Meanings ? - 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: Meanings ? (/showthread.php?tid=465579)



Meanings ? - AnonScripter - 22.09.2013

can somebody tell me what is these numbers meaning ?
reason[50], string[200]
if(sscanf(params, "us[50]")


Re: Meanings ? - Krakuski - 23.09.2013

the [50] and the [200] mean that they are the amount of letters or values you can put into a text..

Example:
pawn Код:
public OnPlayerConnect(playerid)
{
    new string[200]; //this means i can only have 200 letters
    format(string, sizeof(string), "SERVER: Welcome %s", RPN(playerid)); // in this line here
    SendClientMessage(playerid, 0xFFFFFFFF, string);
    return 1;
}



Re: Meanings ? - Dubya - 23.09.2013

The [amount], is the cellbye size of your string.
More information: https://sampforum.blast.hk/showthread.php?tid=55261


Re: Meanings ? - AnonScripter - 23.09.2013

pawn Код:
new targetid, reason[5];
    if(sscanf(params, "us[5]", targetid, reason))");
this means that the reason is only can be 5 letters ?


Re: Meanings ? - Konstantinos - 23.09.2013

Quote:
Originally Posted by AnonScripter
Посмотреть сообщение
pawn Код:
new targetid, reason[5];
    if(sscanf(params, "us[5]", targetid, reason))");
this means that the reason is only can be 5 letters ?
4 characters + NULL termination

PS: By the way, it's:
pawn Код:
if(sscanf(params, "us[5]", targetid, reason)) // send an error message about the syntax



Re: Meanings ? - PrinceKumar - 23.09.2013

it means that your msg need to be in 5 bytes otherwise it will cut your msg


Re: Meanings ? - AnonScripter - 23.09.2013

5 bytes ? how to make it 50 characters maximum and send error client message if it's more than 50 ?


Re: Meanings ? - PrinceKumar - 23.09.2013

use value above >50 u can use 128, 64, 32, 8, 1024,1200 ... it depends on you that how much big string you want ... if you want not a big string then in these cases you can use 64, 128, 256, 512
edit: i haven't mentioned here that how to give them message if player string is more than allowed values..
n u can easily check that .. using..
if(strlen(reason) > here your charc.. value) SendClientMessage(.......);


Re: Meanings ? - Konstantinos - 23.09.2013

pawn Код:
new targetid, reason[50];
if(sscanf(params, "us[50]", targetid, reason)) return SendClientMessage(playerid, -1, "Syntax: /command_here <ID/Part Of Name> <reason>");
if(strlen(reason) > 50) return SendClientMessage(playerid, -1, "Reason can be only 50 characters");
Even though, if reason exceed 50 characters - sscanf will give a warning in the console.


Re: Meanings ? - AnonScripter - 23.09.2013

thanks all, that was helpful