SA-MP Forums

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

Reply
 
Thread Tools Display Modes
Old 20/10/2018, 06:43 PM   #1
Belengher
Big Clucker
 
Join Date: May 2015
Posts: 194
Reputation: 0
Default xyz.pwn(22109) : warning 214: possibly a "const" array argument was intended: "string"

Help pls...


I update pawn compiler, last version and i recived this warning


xyz.pwn(22109) : warning 214: possibly a "const" array argument was intended: "string"

22109:
Quote:
stock CheckName(playerid, string[])
{
if(strfind(string, ".", true) == 0) return Kick(playerid);
new numbers, lenght = strlen(string);
for(new i; i < lenght; i++)
{
if(string[i] >= '0' && string[i] <= '9') numbers ++;
}
if(numbers < 5) return 0;
else if(numbers < Kick(playerid);
else BanEx(playerid, "Invalid Name");
return 1;
}
Belengher is offline   Reply With Quote
Old 20/10/2018, 06:47 PM   #2
Calisthenics
Huge Clucker
 
Join Date: May 2018
Posts: 404
Reputation: 69
Default Re: xyz.pwn(22109) : warning 214: possibly a "const" array argument was intended: "string"

Code:
CheckName(playerid, const string[])
Any array that is never modified should be a constant.
Calisthenics is offline   Reply With Quote
Old 20/10/2018, 07:05 PM   #3
Belengher
Big Clucker
 
Join Date: May 2015
Posts: 194
Reputation: 0
Default Re: xyz.pwn(22109) : warning 214: possibly a "const" array argument was intended: "string"

Quote:
Originally Posted by Calisthenics View Post
Code:
CheckName(playerid, const string[])
Any array that is never modified should be a constant.

Thank you bro..

And this? thank you

warning 239: literal array/string passed to a non-const parameter
Quote:
if(PlayerInfo[playerid][pTeam] != 5) SetPlayerCriminal(killerid, "Unknown", "First Degree Murder", 1);
or
warning 239: literal array/string passed to a non-const parameter
Quote:
if(PlayerProfile[playerid]) cmd_profile(playerid, "0");
Belengher is offline   Reply With Quote
Old 20/10/2018, 07:16 PM   #4
Calisthenics
Huge Clucker
 
Join Date: May 2018
Posts: 404
Reputation: 69
Default Re: xyz.pwn(22109) : warning 214: possibly a "const" array argument was intended: "string"

The compiler does not like to pass a string directly with the latest version.

pawn Code:
static profile_params[] = "0";
if(PlayerProfile[playerid]) cmd_profile(playerid, profile_params);

Since the text in `SetPlayerCriminal` function can be used in other parts of the script, create constants globally.
Calisthenics is offline   Reply With Quote
Old 20/10/2018, 07:29 PM   #5
Belengher
Big Clucker
 
Join Date: May 2015
Posts: 194
Reputation: 0
Default Re: xyz.pwn(22109) : warning 214: possibly a "const" array argument was intended: "string"

Quote:
Originally Posted by Calisthenics View Post
The compiler does not like to pass a string directly with the latest version.

pawn Code:
static profile_params[] = "0";
if(PlayerProfile[playerid]) cmd_profile(playerid, profile_params);

Since the text in `SetPlayerCriminal` function can be used in other parts of the script, create constants globally.
It's ok??

BEFORE:
Quote:
forward SetPlayerCriminal(playerid, declare[], reason[], wanted);
AFTER:
Quote:
forward SetPlayerCriminal(playerid, const declare[], const reason[], wanted);
?
Belengher is offline   Reply With Quote
Old 20/10/2018, 07:42 PM   #6
Calisthenics
Huge Clucker
 
Join Date: May 2018
Posts: 404
Reputation: 69
Default Re: xyz.pwn(22109) : warning 214: possibly a "const" array argument was intended: "string"

The warning is not about expecting constant array but passing a literal value. Make a crime list that you can access anywhere.
pawn Code:
enum
{
    CRIME_UNKNOWN, // constant, its value is 0
    CRIME_FIRST_DEGREE_MURDER // constant, its value is 1
}

new const CrimeList[][] =
{
    "Unknown", // index 0
    "First Degree Murder" // index 1
};
pawn Code:
if(PlayerInfo[playerid][pTeam] != 5) SetPlayerCriminal(killerid, CrimeList[CRIME_UNKNOWN], CrimeList[CRIME_FIRST_DEGREE_MURDER ], 1);
Calisthenics is offline   Reply With Quote
Old 20/10/2018, 08:01 PM   #7
Belengher
Big Clucker
 
Join Date: May 2015
Posts: 194
Reputation: 0
Default Re: xyz.pwn(22109) : warning 214: possibly a "const" array argument was intended: "string"

Quote:
Originally Posted by Calisthenics View Post
The warning is not about expecting constant array but passing a literal value. Make a crime list that you can access anywhere.
pawn Code:
enum
{
    CRIME_UNKNOWN, // constant, its value is 0
    CRIME_FIRST_DEGREE_MURDER // constant, its value is 1
}

new const CrimeList[][] =
{
    "Unknown", // index 0
    "First Degree Murder" // index 1
};
pawn Code:
if(PlayerInfo[playerid][pTeam] != 5) SetPlayerCriminal(killerid, CrimeList[CRIME_UNKNOWN], CrimeList[CRIME_FIRST_DEGREE_MURDER ], 1);
ok. but
And if I put it as I said, is not it ok? I'm not receiving warning.

Like this:
BEFORE:
Quote:
Quote:
forward SetPlayerCriminal(playerid, declare[], reason[], wanted);
AFTER:
Quote:
Quote:
forward SetPlayerCriminal(playerid, const declare[], const reason[], wanted);
?
Belengher is offline   Reply With Quote
Old 20/10/2018, 08:09 PM   #8
Calisthenics
Huge Clucker
 
Join Date: May 2018
Posts: 404
Reputation: 69
Default Re: xyz.pwn(22109) : warning 214: possibly a "const" array argument was intended: "string"

I did not know the warning can be fixed this way too, thanks. Yes, it is okay and now that I look at your code and the warning, your solution makes even more sense.
Calisthenics is offline   Reply With Quote
Old 20/10/2018, 08:22 PM   #9
Belengher
Big Clucker
 
Join Date: May 2015
Posts: 194
Reputation: 0
Default Re: xyz.pwn(22109) : warning 214: possibly a "const" array argument was intended: "string"

thank you
Belengher 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 224: indeterminate array size in "sizeof" expression (symbol "maxlength") SapMan Scripting Help 13 14/10/2018 11:04 PM
Command warning (params) warning 224: indeterminate array size in "sizeof" expression (symbol "maxlength") Riwerry Scripting Help 1 24/05/2014 11:54 PM
warning 224: indeterminate array size in "sizeof" expression (symbol "") Fierro Scripting Help 7 12/10/2013 03:59 PM
[SOLVED]warning 224: indeterminate array size in "sizeof" expression (symbol "") LarzI Help Archive 2 22/12/2009 05:32 AM


All times are GMT. The time now is 01:21 AM.


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