ZCMD: Problem with Sscanf fucntion
#1

pawn Код:
CMD:label(playerid, params[])
{
    new tmp[1024];
    sscanf(cmd, "{s[256]}p<->s[1024]", tmp);
    if(strlen(tmp)<=0 || strlen(tmp)>50) return Warn(playerid,"{ff0000}USAGE: /label [text from 1 to 50 characters]");
    new Float:x,Float:y,Float:z;
    new ft[256];
    new tt[100];
    GetPlayerPos(playerid,x,y,z);

    if(IsValidDynamic3DTextLabel(Label[playerid]))
    {
        DestroyDynamic3DTextLabel(Label[playerid]);
        format(tt,sizeof(tt),"%d",Label_ID[playerid]);
        dini_Unset(LABELSFILE,tt);

        SAVED_LABEL[Label_ID[playerid]]=Text3D:-1;
        Label_ID[playerid]=-1;
        Label[playerid]=Text3D:-1;
    }
    Label[playerid]=CreateDynamic3DTextLabel(tmp,0xFFFFFFFF, x,y,z,500);

    new d=0;
    new idrd=0;
    new zoneidx;
    while (d==0)
    {
        idrd++;

        if(SAVED_LABEL[idrd]!=Text3D:-1) d=0;
        else d=1, zoneidx=idrd;
    }
    format(tt,sizeof(tt),"%d",zoneidx);
    Label_ID[playerid]=zoneidx;
    SAVED_LABEL[zoneidx]=Label[playerid];
    format(ft,sizeof(ft),"%f %f %f %s",x,y,z,tmp);
    dini_Set(LABELSFILE,tt,ft);

    new file[256];
    GetPlayerName(playerid, pname, sizeof(pname));
    format(file,sizeof(file),USERFILE,pname);
    dini_IntSet(file,"SAFE_LABEL",zoneidx);

    Inform(playerid,"{00ff00}You have just created a text label at this place!");
    return 1;
}
problem = sscanf(cmd, "{s[256]}p<->s[1024]", tmp);


:\ C:\Documents and Settings\PhongLan\Desktop\New Folder (6)\gamemodes\UCW.pwn(266 : error 017: undefined symbol "cmd"

pawn Код:
CMD:safe(playerid, params[])
{
    new idx;
    new cmd[256];
    new tmp[512];
    tmp = strtok(cmd, idx);
    if(strval(tmp)<=0 || strval(tmp)>15) return Warn(playerid,"{ff0000}USAGE: /safe [radius:1-15]");
    if(IsPlayerInAnyDynamicArea(playerid)) return Warn(playerid,"{ff0000}You are in another safe area! Come to another place!");
    new Float:x,Float:y,Float:z;
    new ft[256];
    new tt[100];
    GetPlayerPos(playerid,x,y,z);

    if(IsValidDynamicArea(Zone[playerid][0]))
    {
        DestroyDynamicArea(Zone[playerid][0]);
        format(tt,sizeof(tt),"%d",Zone[playerid][1]);
        dini_Unset(ZONESFILE,tt);

        SAVED_ZONE[Zone[playerid][1]]=-1;
        Zone[playerid][1]=-1;
        Zone[playerid][0]=-1;
    }
    Zone[playerid][0]=CreateDynamicCircle(x,y,strval(tmp));

    new d=0;
    new idrd=0;
    new zoneidx;
    while (d==0)
    {
        idrd++;

        if(SAVED_ZONE[idrd]!=-1) d=0;
        else d=1, zoneidx=idrd;
    }
    format(tt,sizeof(tt),"%d",zoneidx);
    Zone[playerid][1]=zoneidx;
    SAVED_ZONE[zoneidx]=Zone[playerid][0];
    format(ft,sizeof(ft),"%f %f %d",x,y,strval(tmp));
    dini_Set(ZONESFILE,tt,ft);

    new file[256];
    GetPlayerName(playerid, pname, sizeof(pname));
    format(file,sizeof(file),USERFILE,pname);
    dini_IntSet(file,"SAFE_ZONE",zoneidx);

    Inform(playerid,"You have just created a safe zone at this place! Only can build here now!");
    return 1;
}

CMD:delsafe(playerid, params[])
{
    new tt[100];

    if(IsValidDynamicArea(Zone[playerid][0]))
    {
        DestroyDynamicArea(Zone[playerid][0]);
        format(tt,sizeof(tt),"%d",Zone[playerid][1]);
        dini_Unset(ZONESFILE,tt);

        SAVED_ZONE[Zone[playerid][1]]=-1;
        Zone[playerid][1]=-1;
        Zone[playerid][0]=-1;
        Inform(playerid,"{00ff00}You have just deleted your safe zone!");
    }
    else
    {
        Warn(playerid,"{ff0000}You don't have any safe zone created!");
    }
    return 1;
}

CMD:label(playerid, params[])
{
    new tmp[1024];
    sscanf(cmd, "{s[256]}p<->s[1024]", tmp);
    if(strlen(tmp)<=0 || strlen(tmp)>50) return Warn(playerid,"{ff0000}USAGE: /label [text from 1 to 50 characters]");
    new Float:x,Float:y,Float:z;
    new ft[256];
    new tt[100];
    GetPlayerPos(playerid,x,y,z);

    if(IsValidDynamic3DTextLabel(Label[playerid]))
    {
        DestroyDynamic3DTextLabel(Label[playerid]);
        format(tt,sizeof(tt),"%d",Label_ID[playerid]);
        dini_Unset(LABELSFILE,tt);

        SAVED_LABEL[Label_ID[playerid]]=Text3D:-1;
        Label_ID[playerid]=-1;
        Label[playerid]=Text3D:-1;
    }
    Label[playerid]=CreateDynamic3DTextLabel(tmp,0xFFFFFFFF, x,y,z,500);

    new d=0;
    new idrd=0;
    new zoneidx;
    while (d==0)
    {
        idrd++;

        if(SAVED_LABEL[idrd]!=Text3D:-1) d=0;
        else d=1, zoneidx=idrd;
    }
    format(tt,sizeof(tt),"%d",zoneidx);
    Label_ID[playerid]=zoneidx;
    SAVED_LABEL[zoneidx]=Label[playerid];
    format(ft,sizeof(ft),"%f %f %f %s",x,y,z,tmp);
    dini_Set(LABELSFILE,tt,ft);

    new file[256];
    GetPlayerName(playerid, pname, sizeof(pname));
    format(file,sizeof(file),USERFILE,pname);
    dini_IntSet(file,"SAFE_LABEL",zoneidx);

    Inform(playerid,"{00ff00}You have just created a text label at this place!");
    return 1;
}

CMD:dellabel(playerid, params[])
{

    new tt[100];
    if(IsValidDynamic3DTextLabel(Label[playerid]))
    {
        DestroyDynamic3DTextLabel(Label[playerid]);
        format(tt,sizeof(tt),"%d",Label_ID[playerid]);
        dini_Unset(LABELSFILE,tt);

        SAVED_LABEL[Label_ID[playerid]]=Text3D:-1;
        Label_ID[playerid]=-1;
        Label[playerid]=Text3D:-1;
        Inform(playerid,"{00ff00}You have just deleted your text label!");
    }
    else
    {
        Warn(playerid,"{ff0000}You don't have any label created!");
    }

    return 1;
}
These commands won't Work went i type =.=
Reply
#2

You are using some functions from strcmp.

Commands in ZCMD with sscanf go like this.

pawn Код:
if(sscanf(params, "us[105]", targetid,reason)) return SendClientMessage(playerid,-1," /ban [playerid] [reason]");
Reply
#3

can you help me fix it =.= ? seriously
Reply
#4

Try working with this command like I edited.

pawn Код:
CMD:label(playerid, params[])
{
    new tmp[1024];
    if(sscanf(params, "s[1024]", tmp)) return SendClientMessage(playerid,-1,"{ff0000}/label [text] [text from 1 to 50 characters]");
    new Float:x,Float:y,Float:z;
    new ft[256];
    new tt[100];
    GetPlayerPos(playerid,x,y,z);

    if(IsValidDynamic3DTextLabel(Label[playerid]))
    {
        DestroyDynamic3DTextLabel(Label[playerid]);
        format(tt,sizeof(tt),"%d",Label_ID[playerid]);
        dini_Unset(LABELSFILE,tt);

        SAVED_LABEL[Label_ID[playerid]]=Text3D:-1;
        Label_ID[playerid]=-1;
        Label[playerid]=Text3D:-1;
    }
    Label[playerid]=CreateDynamic3DTextLabel(tmp,0xFFFFFFFF, x,y,z,500);

    new d=0;
    new idrd=0;
    new zoneidx;
    while (d==0)
    {
        idrd++;

        if(SAVED_LABEL[idrd]!=Text3D:-1) d=0;
        else d=1, zoneidx=idrd;
    }
    format(tt,sizeof(tt),"%d",zoneidx);
    Label_ID[playerid]=zoneidx;
    SAVED_LABEL[zoneidx]=Label[playerid];
    format(ft,sizeof(ft),"%f %f %f %s",x,y,z,tmp);
    dini_Set(LABELSFILE,tt,ft);

    new file[256];
    GetPlayerName(playerid, pname, sizeof(pname));
    format(file,sizeof(file),USERFILE,pname);
    dini_IntSet(file,"SAFE_LABEL",zoneidx);

    Inform(playerid,"{00ff00}You have just created a text label at this place!");
    return 1;
}
Reply
#5

Quote:
Originally Posted by ******
Посмотреть сообщение
NEVER EVER use "sscanf" with just "s" in it!
Elaborate? I'd like to know why as well. What would you do if you have something like this:

pawn Код:
new text[128];
if(sscanf(params, "s",text)) return SCM(playerid, color, "Usage: /createlabel [text]");
Reply
#6

Quote:
Originally Posted by ******
Посмотреть сообщение
Just use "params" directly! In the next version, doing just "s" actually gives a warning in the console.
Could you specify an example? Would it be something as so:
pawn Код:
new text[128];
if(sscanf(params)) return scm blah blah. // If so, how would it detect the parameters of the command?
Reply
#7

Quote:
Originally Posted by ******
Посмотреть сообщение
No, you don't need "text" at all - you already have a variable that contains the string you want, and it is called "params"!
Hm, alright. Thanks for the help.
Reply
#8

pawn Код:
CMD:safe(playerid, params[])
{
    new idx;
    new cmd[256];
    new tmp[512];
    tmp = strtok(cmd, idx);
    if(strval(tmp)<=0 || strval(tmp)>15) return Warn(playerid,"{ff0000}USAGE: /safe [radius:1-15]");
    if(IsPlayerInAnyDynamicArea(playerid)) return Warn(playerid,"{ff0000}You are in another safe area! Come to another place!");
    new Float:x,Float:y,Float:z;
    new ft[256];
    new tt[100];
    GetPlayerPos(playerid,x,y,z);

    if(IsValidDynamicArea(Zone[playerid][0]))
    {
        DestroyDynamicArea(Zone[playerid][0]);
        format(tt,sizeof(tt),"%d",Zone[playerid][1]);
        dini_Unset(ZONESFILE,tt);

        SAVED_ZONE[Zone[playerid][1]]=-1;
        Zone[playerid][1]=-1;
        Zone[playerid][0]=-1;
    }
    Zone[playerid][0]=CreateDynamicCircle(x,y,strval(tmp));

    new d=0;
    new idrd=0;
    new zoneidx;
    while (d==0)
    {
        idrd++;

        if(SAVED_ZONE[idrd]!=-1) d=0;
        else d=1, zoneidx=idrd;
    }
    format(tt,sizeof(tt),"%d",zoneidx);
    Zone[playerid][1]=zoneidx;
    SAVED_ZONE[zoneidx]=Zone[playerid][0];
    format(ft,sizeof(ft),"%f %f %d",x,y,strval(tmp));
    dini_Set(ZONESFILE,tt,ft);

    new file[256];
    GetPlayerName(playerid, pname, sizeof(pname));
    format(file,sizeof(file),USERFILE,pname);
    dini_IntSet(file,"SAFE_ZONE",zoneidx);

    Inform(playerid,"You have just created a safe zone at this place! Only can build here now!");
    return 1;
}
this never work went i preass /safe 1-)15
Reply
#9

nevermind problem Fixed
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)