SA-MP Forums Archive
Must be assigned to an array - 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: Must be assigned to an array (/showthread.php?tid=571405)



Must be assigned to an array - DonBonanno - 18.04.2015

Код:
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..


Re: Must be assigned to an array - Sledgehammer - 18.04.2015

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]);


Re: Must be assigned to an array - DonBonanno - 18.04.2015

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..


Re: Must be assigned to an array - Jefff - 18.04.2015

In enum you got

pMotivMandat

but must be

pMotivMandat[64]


Re: Must be assigned to an array - Sledgehammer - 18.04.2015

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]


Re: Must be assigned to an array - ikey07 - 18.04.2015

For these things there is strmind() for it

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


Re: Must be assigned to an array - DonBonanno - 18.04.2015

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..


Re: Must be assigned to an array - ikey07 - 18.04.2015

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.


Re: Must be assigned to an array - DonBonanno - 18.04.2015

And what i need to add ?


Re: Must be assigned to an array - Godey - 10.02.2016

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

pMotivMandat

but must be

pMotivMandat[64]
Thanks!!!!