I'm gonna go nuts; help. - 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: I'm gonna go nuts; help. (
/showthread.php?tid=455745)
I'm gonna go nuts; help. -
SilencedPistol - 03.08.2013
Seriously, what's wrong with this damn thing?
pawn Код:
error 006: must be assigned to an array
Here's the whole code to my /setrank command of which I'm trying to make work.
pawn Код:
CMD:setrank(playerid, params[])
{
new id;
new name[MAX_PLAYER_NAME];
new rankname[128];
if(PlayerInfo[playerid][pFactionLeader] == 1 || PlayerInfo[playerid][pFactionAMember] == 1)
{
if(!sscanf(params, "us", id, rankname)) return SendClientMessage(playerid, COLOR_USAGE, "USAGE: /setrank [playerid] [rankname]");
if(id == INVALID_PLAYER_ID) return SendClientMessage(playerid, COLOR_ERROR, "ERROR: This player is not connected.");
if(id == PlayerInfo[playerid][pFaction] == 0) return SendClientMessage(playerid, COLOR_ERROR, "ERROR: This player is not a member of your faction.");
PlayerInfo[playerid][pRank] = rankname;
new str[128];
format(str,sizeof(str), "INFO: %s's rank was changed to: %s.", name, rankname);
SendClientMessage(playerid, COLOR_INFO, str);
return 1;
}
else return SendClientMessage(playerid, COLOR_ERROR, "ERROR: You are unauthorized to use this command.");
}
Re: I'm gonna go nuts; help. -
-Prodigy- - 03.08.2013
Try this:
pawn Код:
// Put this at the top of your script
#define strcpy(%0,%1,%2) strcat((%0[0] = '\0', %0), %1, %2)
// and replace:
PlayerInfo[playerid][pRank] = rankname;
// with:
strcpy(PlayerInfo[playerid][pRank], rankname);
Re: I'm gonna go nuts; help. -
Ada32 - 03.08.2013
Код:
PlayerInfo[playerid][pRank] = rankname;
This line^ is what's producing the error. pRank must be an array. And also it'd be in your best interest to specify a size for a string when asking sscanf to do stuff, otherwise it'll get angry and generate an ugly warning on run-time.
Re: I'm gonna go nuts; help. -
Marricio - 03.08.2013
Like Ada32 said,
pawn Код:
PlayerInfo[playerid][pRank] = rankname;
^ That is your problem, you're defining pRank as a string but in a "integer way". This is the correct way
pawn Код:
format( PlayerInfo[playerid][pRank], sizeof PlayerInfo[playerid][pRank], "%s", rankname);
Also, in the sscanf line you need to add the string's size next to the denominator, like this.
pawn Код:
if(!sscanf(params, "us[128]", id, rankname)) return SendClientMessage(playerid, COLOR_USAGE, "USAGE: /setrank [playerid] [rankname]");