String error
#1

pawn Код:
if(dialogid == DIALOG_ATTACH_OBJECT2_SELECTION)
    {
        if(!response)
        {   ShowPlayerDialog(playerid,DIALOG_ATTACH_OBJECT_SELECTION,DIALOG_STYLE_LIST,"Player Objects/Attachment: (Select Object Path)","Path:1 :: "COL_GREY"Server Objects Menu\n"COL_WHITE"Path:2 :: "COL_GREY"Custom Object","Next(>>)","Back(<<)");    }
        if(response)
        {
            if(!strlen(inputtext))return SendClientMessage(playerid,-1,"PLAYER: You can't leave the coloumn blank."),ShowPlayerDialog(playerid,DIALOG_ATTACH_OBJECT2_SELECTION,DIALOG_STYLE_INPUT,"Player Objects/Attachment: (Insert objectid)",""COL_WHITE"Put your custom objectid below, You can also take help from ''http://wiki.sa-mp.com''.","Edit","Back(<<)");
            if(!IsNumeric(inputtext)) return SendClientMessage(playerid,-1,"PLAYER: You can't fill a object name, only object id's allowed."),ShowPlayerDialog(playerid,DIALOG_ATTACH_OBJECT2_SELECTION,DIALOG_STYLE_INPUT,"Player Objects/Attachment: (Insert objectid)",""COL_WHITE"Put your custom objectid below, You can also take help from ''http://wiki.sa-mp.com''.","Edit","Back(<<)");
            new obj;
            if(!sscanf(inputtext, "i", obj))
            {
                if(GetPVarInt(playerid, "AttachmentUsed") == 1) EditAttachedObject(playerid, obj);
                else
                {
                    SetPVarInt(playerid, "AttachmentModelSel", obj);
                    new string[257];
                    new dialog[500];
                    for(new x;x<sizeof(AttachmentBones);x++)
                    {
                        format(string, sizeof(string), "Bone:%s\n", AttachmentBones[x]);
                        strcat(dialog,string);
                    }
                    ShowPlayerDialog(playerid, DIALOG_ATTACH_BONE_SELECTION, DIALOG_STYLE_LIST, \
                    "{FF0000}Attachment Modification - Bone Selection", dialog, "Select", "Cancel");
                }
            }
        }
        return 1;}
I got this error warning 219: local variable "string" shadows a variable at a preceding level
Reply
#2

Give this a shot:

pawn Код:
if(dialogid == DIALOG_ATTACH_OBJECT2_SELECTION)
    {
        if(!response) return ShowPlayerDialog(playerid,DIALOG_ATTACH_OBJECT_SELECTION,DIALOG_STYLE_LIST,"Player Objects/Attachment: (Select Object Path)","Path:1 :: "COL_GREY"Server Objects Menu\n"COL_WHITE"Path:2 :: "COL_GREY"Custom Object","Next(>>)","Back(<<)");
        if(!strlen(inputtext))
        {
            SendClientMessage(playerid,-1,"PLAYER: You can't leave the coloumn blank.");
            return ShowPlayerDialog(playerid,DIALOG_ATTACH_OBJECT2_SELECTION,DIALOG_STYLE_INPUT,"Player Objects/Attachment: (Insert objectid)",""COL_WHITE"Put your custom objectid below, You can also take help from ''http://wiki.sa-mp.com''.","Edit","Back(<<)");
        }
        if(!IsNumeric(inputtext))
        {
            SendClientMessage(playerid,-1,"PLAYER: You can't fill a object name, only object id's allowed.");
            return ShowPlayerDialog(playerid,DIALOG_ATTACH_OBJECT2_SELECTION,DIALOG_STYLE_INPUT,"Player Objects/Attachment: (Insert objectid)",""COL_WHITE"Put your custom objectid below, You can also take help from ''http://wiki.sa-mp.com''.","Edit","Back(<<)");
        }
        new obj;
        if(!sscanf(inputtext, "i", obj))
        {
            if(GetPVarInt(playerid, "AttachmentUsed") == 1) EditAttachedObject(playerid, obj);
            else
            {
                SetPVarInt(playerid, "AttachmentModelSel", obj);
                new dstr[180];
                for(new x; x != sizeof(AttachmentBones); ++x) format(dstr, sizeof(dstr), "%s\nBone:%s", string, AttachmentBones[x]);
                ShowPlayerDialog(playerid, DIALOG_ATTACH_BONE_SELECTION, DIALOG_STYLE_LIST, "{FF0000}Attachment Modification - Bone Selection", dstr, "Select", "Cancel");
            }
        }
        return 1;
    }
What this error is telling you, is you have another variable named 'string' being used somewhere else. (new string)

So in your script you have two 'new' variables called 'string'. The other 'new string' may be a global variable outside any callbacks, but simply changing the variable name (I changed it to 'dstr') will fix the error. I also did a few beneficial adjustments to the script.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)