Meanings ?
#1

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

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;
}
Reply
#3

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

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

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
Reply
#6

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

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

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(.......);
Reply
#9

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

thanks all, that was helpful
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)