SA-MP Forums Archive
Error in a command - 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: Error in a command (/showthread.php?tid=423226)



Error in a command - DerickClark - 17.03.2013

sscanf warning: Strings without a length are deprecated, please add a destination size.


Код:
COMMAND:label(playerid,params[])
{
if (APlayerData[playerid][PlayerLevel] >= 7)
{
new string[160],Float: X, Float: Y, Float: Z,text[100],distance,color;
GetPlayerPos(playerid, X,Y,Z);
if(sscanf(params,"sxd",text,color,distance)) return SendClientMessage(playerid,0xFB9204FF,"USAGE: /label [text] [color] [distance]");
Create3DTextLabel(text,color,X,Y,Z,distance,GetPlayerVirtualWorld(playerid));
format(string,sizeof(string),"Create3DTextLabel(\"%s\",color,%f, %f, %f,%d,%d);",text,X,Y,Z,distance,GetPlayerVirtualWorld(playerid));
SaveToLog("labels",string);
}
return 1;
}



Re: Error in a command - Scrillex - 17.03.2013

pawn Код:
if(sscanf(params,"s[30]xd",
30 = just example
You forgot to string sscanf!


Re: Error in a command - DerickClark - 17.03.2013

Plz send full code.gave me errors.


Re: Error in a command - Scrillex - 17.03.2013

Read my comment! // s[30] You for got to set how big is string in sscanf! (30 is just example!)
pawn Код:
COMMAND:label(playerid,params[])
{
    if (APlayerData[playerid][PlayerLevel] >= 7)
    {
        new string[160],Float: X, Float: Y, Float: Z,text[100],distance,color;
        GetPlayerPos(playerid, X,Y,Z);
        if(sscanf(params,"s[30]xd",text,color,distance)) return SendClientMessage(playerid,0xFB9204FF,"USAGE: /label [text] [color] [distance]"); // s[30] You for got to set how big is string in sscanf! (30 is just example!)
        Create3DTextLabel(text,color,X,Y,Z,distance,GetPlayerVirtualWorld(playerid));
        format(string,sizeof(string),"Create3DTextLabel(\"%s\",color,%f, %f, %f,%d,%d);",text,X,Y,Z,distance,GetPlayerVirtualWorld(playerid));
        SaveToLog("labels",string);
    }
    return 1;
}