SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help

Reply
 
Thread Tools Display Modes
Old 10/02/2020, 10:14 AM   #1
josh
Big Clucker
 
Join Date: Jul 2019
Posts: 73
Reputation: 3
Default literal array/string

Hi!

Why when I use this function I see some warnings how can I fix this?


Code:
warning 239: literal array/string passed to a non-const parameter
warning 239: literal array/string passed to a non-const parameter
warning 239: literal array/string passed to a non-const parameter
warning 239: literal array/string passed to a non-const parameter
warning 239: literal array/string passed to a non-const parameter
warning 239: literal array/string passed to a non-const parameter
warning 239: literal array/string passed to a non-const parameter

pawn Code:
stock ShowModelSelectionMenu(playerid, ListID, header_text[], dialogBGcolor = 0x4A5A6BBB, previewBGcolor = 0x88888899 , tdSelectionColor = 0xFFFF00AA)
{
    if(!(0 <= ListID < mS_TOTAL_LISTS && gLists[ListID][mS_LIST_START] != gLists[ListID][mS_LIST_END])) return 0;
    mS_DestroySelectionMenu(playerid);
    SetPVarInt(playerid, "mS_list_page", 0);
    SetPVarInt(playerid, "mS_list_id", ListID);
    SetPVarInt(playerid, "mS_list_active", 1);
    SetPVarInt(playerid, "mS_list_time", GetTickCount());

    gBackgroundTextDrawId[playerid] = mS_CreatePlayerBGTextDraw(playerid, mS_DIALOG_BASE_X, mS_DIALOG_BASE_Y + 20.0, mS_DIALOG_WIDTH, mS_DIALOG_HEIGHT, dialogBGcolor);
    gHeaderTextDrawId[playerid] = mS_CreatePlayerHeaderTextDraw(playerid, mS_DIALOG_BASE_X, mS_DIALOG_BASE_Y, header_text);
    gCurrentPageTextDrawId[playerid] = mS_CreateCurrentPageTextDraw(playerid, mS_DIALOG_WIDTH - 30.0, mS_DIALOG_BASE_Y + 15.0);
    gNextButtonTextDrawId[playerid] = mS_CreatePlayerDialogButton(playerid, mS_DIALOG_WIDTH - 30.0, mS_DIALOG_BASE_Y+mS_DIALOG_HEIGHT+100.0, 50.0, 16.0, mS_NEXT_TEXT);
    gPrevButtonTextDrawId[playerid] = mS_CreatePlayerDialogButton(playerid, mS_DIALOG_WIDTH - 90.0, mS_DIALOG_BASE_Y+mS_DIALOG_HEIGHT+100.0, 50.0, 16.0, mS_PREV_TEXT);
    gCancelButtonTextDrawId[playerid] = mS_CreatePlayerDialogButton(playerid, mS_DIALOG_WIDTH - 150.0, mS_DIALOG_BASE_Y+mS_DIALOG_HEIGHT+100.0, 50.0, 16.0, mS_CANCEL_TEXT);

    SetPVarInt(playerid, "mS_previewBGcolor", previewBGcolor);
    mS_ShowPlayerMPs(playerid);
    mS_UpdatePageTextDraw(playerid);

    SelectTextDraw(playerid, tdSelectionColor);
    return 1;
}
josh is offline   Reply With Quote
Old 11/02/2020, 05:48 AM   #2
josh
Big Clucker
 
Join Date: Jul 2019
Posts: 73
Reputation: 3
Default Re: literal array/string

Anyone?
josh is offline   Reply With Quote
Old 11/02/2020, 06:48 AM   #3
IZenta
Little Clucker
 
Join Date: Jan 2020
Location: Indonesia
Posts: 43
Reputation: 16
Default Re: literal array/string

Where the warning line -_
__________________
Discord: ZTzTopia#0001
IZenta is offline   Reply With Quote
Old 11/02/2020, 07:30 AM   #4
josh
Big Clucker
 
Join Date: Jul 2019
Posts: 73
Reputation: 3
Default Re: literal array/string

Quote:
Originally Posted by IZenta View Post
Where the warning line -_
Code:
stock ShowModelSelectionMenu(playerid, ListID, header_text[], dialogBGcolor = 0x4A5A6BBB, previewBGcolor = 0x88888899 , tdSelectionColor = 0xFFFF00AA)
josh is offline   Reply With Quote
Old 11/02/2020, 08:19 AM   #5
Calisthenics
High-roller
 
Join Date: May 2018
Posts: 1,229
Reputation: 205
Default Re: literal array/string

Open mSelection.inc file.

Change:
pawn Code:
stock PlayerText:mS_CreatePlayerDialogButton(playerid, Float:Xpos, Float:Ypos, Float:Width, Float:Height, button_text[])
to:
pawn Code:
stock PlayerText:mS_CreatePlayerDialogButton(playerid, Float:Xpos, Float:Ypos, Float:Width, Float:Height, const button_text[])

Change:
pawn Code:
stock PlayerText:mS_CreatePlayerHeaderTextDraw(playerid, Float:Xpos, Float:Ypos, header_text[])
to:
pawn Code:
stock PlayerText:mS_CreatePlayerHeaderTextDraw(playerid, Float:Xpos, Float:Ypos, const header_text[])

Change:
pawn Code:
stock ShowModelSelectionMenu(playerid, ListID, header_text[], dialogBGcolor = 0x4A5A6BBB, previewBGcolor = 0x88888899 , tdSelectionColor = 0xFFFF00AA)
to:
pawn Code:
stock ShowModelSelectionMenu(playerid, ListID, const header_text[], dialogBGcolor = 0x4A5A6BBB, previewBGcolor = 0x88888899 , tdSelectionColor = 0xFFFF00AA)

Change:
pawn Code:
stock LoadModelSelectionMenu(f_name[])
to:
pawn Code:
stock LoadModelSelectionMenu(const f_name[])
__________________
Calisthenics is offline   Reply With Quote
Old 11/02/2020, 09:28 AM   #6
josh
Big Clucker
 
Join Date: Jul 2019
Posts: 73
Reputation: 3
Default Re: literal array/string

Quote:
Originally Posted by Calisthenics View Post
Open mSelection.inc file.

Change:
pawn Code:
stock PlayerText:mS_CreatePlayerDialogButton(playerid, Float:Xpos, Float:Ypos, Float:Width, Float:Height, button_text[])
to:
pawn Code:
stock PlayerText:mS_CreatePlayerDialogButton(playerid, Float:Xpos, Float:Ypos, Float:Width, Float:Height, const button_text[])

Change:
pawn Code:
stock PlayerText:mS_CreatePlayerHeaderTextDraw(playerid, Float:Xpos, Float:Ypos, header_text[])
to:
pawn Code:
stock PlayerText:mS_CreatePlayerHeaderTextDraw(playerid, Float:Xpos, Float:Ypos, const header_text[])

Change:
pawn Code:
stock ShowModelSelectionMenu(playerid, ListID, header_text[], dialogBGcolor = 0x4A5A6BBB, previewBGcolor = 0x88888899 , tdSelectionColor = 0xFFFF00AA)
to:
pawn Code:
stock ShowModelSelectionMenu(playerid, ListID, const header_text[], dialogBGcolor = 0x4A5A6BBB, previewBGcolor = 0x88888899 , tdSelectionColor = 0xFFFF00AA)

Change:
pawn Code:
stock LoadModelSelectionMenu(f_name[])
to:
pawn Code:
stock LoadModelSelectionMenu(const f_name[])

When Change:


pawn Code:
stock PlayerText:mS_CreatePlayerDialogButton(playerid, Float:Xpos, Float:Ypos, Float:Width, Float:Height, button_text[])

to

pawn Code:
stock PlayerText:mS_CreatePlayerDialogButton(playerid, Float:Xpos, Float:Ypos, Float:Width, Float:Height, const button_text[])


Code:
error 035: argument type mismatch (argument 4)
When Change:

pawn Code:
stock PlayerText:mS_CreatePlayerHeaderTextDraw(playerid, Float:Xpos, Float:Ypos, header_text[])

to

pawn Code:
stock PlayerText:mS_CreatePlayerHeaderTextDraw(playerid, Float:Xpos, Float:Ypos, const header_text[])

Code:
error 035: argument type mismatch (argument 4)
When Change:


pawn Code:
stock ShowModelSelectionMenu(playerid, ListID, header_text[], dialogBGcolor = 0x4A5A6BBB, previewBGcolor = 0x88888899 , tdSelectionColor = 0xFFFF00AA)


to

pawn Code:
stock ShowModelSelectionMenu(playerid, ListID, const header_text[], dialogBGcolor = 0x4A5A6BBB, previewBGcolor = 0x88888899 , tdSelectionColor = 0xFFFF00AA)



Code:
error 035: argument type mismatch (argument 4)
josh is offline   Reply With Quote
Old 11/02/2020, 09:32 AM   #7
Calisthenics
High-roller
 
Join Date: May 2018
Posts: 1,229
Reputation: 205
Default Re: literal array/string

Change the 4 lines I mentioned to const arrays and now open a_players.inc and change:
pawn Code:
native PlayerText:CreatePlayerTextDraw(playerid, Float:x, Float:y, text[]);

native PlayerTextDrawSetString(playerid, PlayerText:text, string[]);
to:
pawn Code:
native PlayerText:CreatePlayerTextDraw(playerid, Float:x, Float:y, const text[]);

native PlayerTextDrawSetString(playerid, PlayerText:text, const string[]);
__________________
Calisthenics is offline   Reply With Quote
Old 11/02/2020, 09:45 AM   #8
josh
Big Clucker
 
Join Date: Jul 2019
Posts: 73
Reputation: 3
Default Re: literal array/string

Quote:
Originally Posted by Calisthenics View Post
Change the 4 lines I mentioned to const arrays and now open a_players.inc and change:
pawn Code:
native PlayerText:CreatePlayerTextDraw(playerid, Float:x, Float:y, text[]);

native PlayerTextDrawSetString(playerid, PlayerText:text, string[]);
to:
pawn Code:
native PlayerText:CreatePlayerTextDraw(playerid, Float:x, Float:y, const text[]);

native PlayerTextDrawSetString(playerid, PlayerText:text, const string[]);
thxxx But I have more warnings


pawn Code:
task AFKUpdate[10000]()
{
    if(Iter_Count(Player) > MAX_PLAYERS - 100)
    {
        foreach(new i: Player)
        {
            if((playerTabbed[i] > 300 || playerAFK[i] > 300) && PlayerInfo[i][pShopTech] < 1 && PlayerInfo[i][pAdmin] < 4)
            {
                Kick(i);
            }
        }
    }
    return 1;
}

Code:
warning 239: literal array/string passed to a non-const parameter
josh is offline   Reply With Quote
Old 11/02/2020, 09:49 AM   #9
Calisthenics
High-roller
 
Join Date: May 2018
Posts: 1,229
Reputation: 205
Default Re: literal array/string

Post full errors and warnings, preferably file and lines. The code above seems unrelated, might coming from an include file.
__________________
Calisthenics is offline   Reply With Quote
Old 11/02/2020, 10:01 AM   #10
josh
Big Clucker
 
Join Date: Jul 2019
Posts: 73
Reputation: 3
Default Re: literal array/string

Quote:
Originally Posted by Calisthenics View Post
Post full errors and warnings, preferably file and lines. The code above seems unrelated, might coming from an include file.
ok, what about this warning

Code:
warning 239: literal array/string passed to a non-const parameter
pawn Code:
PreloadAnimLib(playerid,const animlib[]) //line warning
{
    ApplyAnimation(playerid,animlib,"null",0.0,0,0,0,0,0,1);
}


When i add const show me this error
Code:
error 035: argument type mismatch (argument 2)
josh is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
warning 239: literal array/string passed to a non-const parameter StRaphael Scripting Help 8 04/01/2020 09:34 AM
warning 239: literal array/string passed to a non-const parameter gui13 Scripting Help 7 18/12/2019 07:52 AM
literal array/string passed to a non-const parameter DuyDang2412 Scripting Help 3 08/07/2019 02:24 AM
ShowPlayerDialog - literal array/string passed to a non-const parameter kaZax Scripting Help 9 18/02/2019 03:49 PM


All times are GMT. The time now is 10:39 AM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.