Must be assigned to an array
#1

Код:
CMD:addwarrant(playerid, params[])
{
	new id, charge[64];
	new faction = PlayerInfo[playerid][pFaction];
	if(faction != LSPD && faction != SD) return SCM(playerid, COLOR_LIGHTRED, "Factiune invalida.");
	if(sscanf(params,"us[64]",id,charge)) return SyntaxMSG(playerid, "/wanted [playerid/Nume] [Descrie infractiunea]");
	if(!PlayerIsOn(id)) return NotConnectedMSG(playerid);
	if(PlayerInfo[id][pMandat] == 1) return SCM(playerid, COLOR_WHITE, "Acest jucator are deja un mandat emis.");
	if(AddCriminalRecord(id, charge, playerid))
	{
		format(msg, sizeof(msg), "[CAUTAT] Suspect: %s, Reporter: %s Infractiune: %s", GetNameEx(id), GetNameEx(playerid), charge);
		SendFactionMessage(LSPD, COLOR_LSPDNEW, msg);
		SCM(playerid, COLOR_WHITE, "Ai adaugat cu succes un mandat pentru persoana respectiva.");
		PlayerInfo[id][pMandat] = 1;
		PlayerInfo[id][pMotivMandat] = charge;
	}
	else
	{
		SCM(playerid, COLOR_LIGHTRED, "Mandatul nu a putut fi emis.");
	}
	return 1;
}
Here is the problem :

Код:
PlayerInfo[id][pMotivMandat] = charge;
charge..
Reply
#2

Please outline what the error is, or what you want the code to do. Thanks.

Edit: You need to format it.

format(PlayerInfo[id][pMotivMandat], sizeof(charge), "%s", PlayerInfo[id][pMotivMandat]);
Reply
#3

I have all code there, what a ... ?

There is a CMD who add a warrant for a player... The error is : Must be assigned to an array

The error line is :

Код:
PlayerInfo[id][pMotivMandat] = charge;
charge = Is a crime description..TEXT..
Reply
#4

In enum you got

pMotivMandat

but must be

pMotivMandat[64]
Reply
#5

You need to format it. Replace "PlayerInfo[id][pMotivMandat] = charge;" with the following:

format(PlayerInfo[id][pMotivMandat], sizeof(charge), "%s", PlayerInfo[id][pMotivMandat]);

Also, Make sure your enum for pMotivMandat is something similar to:

pMotivMandat[64]
Reply
#6

For these things there is strmind() for it

strmid(PlayerInfo[id][pMotivMandat],charge,0,strlen(charge),64); //strmid(destination [], source[], start, end, sizeof());
Reply
#7

Not pMotivMandat is problem...

In database, pMotivMandat have TEXT..The reason of Warrant !!!!
i need to make something like:

new charge = strval(imputtext);
But i don't have imputtext there...i have params and strval is for numbers i think..i need for text..


PlayerInfo[id][pMotivMandat] = REASON OF WARRANT;

PlayerInfo[id]etc is setting to ID the reason..
Reply
#8

in sscanf readme orso check how to get a string with spaces, as I don't use sscanf, but usual strtuk,I modified it so I can get text with spaces as 2nd parameter.

like /warrant playerid [reason]

1st param is playerid
2nd param is reason with spaces like a text.
Reply
#9

And what i need to add ?
Reply
#10

Quote:
Originally Posted by Jefff
Посмотреть сообщение
In enum you got

pMotivMandat

but must be

pMotivMandat[64]
Thanks!!!!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)