SA-MP Forums Archive
Anything wrong? - 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: Anything wrong? (/showthread.php?tid=616585)



Anything wrong? - BrianS123 - 07.09.2016

Hi

I don't got errors/warrnings, but once i try it in game, it works, but the "unknown command" msg show up too, only in this command, if i type another command, it works perfectly..
Код:
CMD:createobject(playerid, params[])
{
	if(!(PlayerInfo[playerid][pAdmin] >= 4)) return SCM(playerid, COLOR_GREY,  "You can't use this command.");
	new oid,omodel,string[128],Float:Pos[3];
	GetPlayerPos(playerid, Pos[0],Pos[1],Pos[2]);
	if(sscanf(params, "dd",oid,omodel)) return SCM(playerid, COLOR_WHITE, "USAGE: /createobject [id] [modelid]");
	if(oid >= MAX_GATES) return SCM(playerid, COLOR_WHITE, "Invalid ID.");
	if(oinfo[oid][oactive] == 0)
	{
	    oinfo[oid][ox] = Pos[0];
	    oinfo[oid][oy] = Pos[1];
	    oinfo[oid][oz] = Pos[2];
	    oinfo[oid][oactive] = 1;
	    oinfo[oid][objectid] = omodel;
	    oinfo[oid][modelid] = CreateDynamicObject(oinfo[oid][objectid],oinfo[oid][ox],oinfo[oid][oy],oinfo[oid][oz],180,180,90,-1,-1,-1,200.0);
	    format(string,sizeof(string), "You have created an object with ID %d and model %d",oid,omodel);
	    SCM(playerid, COLOR_YELLOW, string);
	    SaveAllObjects();
	}
	else
	{
	    SCM(playerid, COLOR_WHITE, "This object is already used.");
	}
	return 1;
}



Re: Anything wrong? - Stinged - 07.09.2016

Install crashdetect and compile with debug info.
Then post the server log it creates here.


Re: Anything wrong? - BrianS123 - 07.09.2016

Done and always no errors/warnings


Re: Anything wrong? - BrianS123 - 07.09.2016

Edit
I got this
Код:
[18:16:08] [debug] Run time error 4: "Array index out of bounds"
[18:16:08] [debug] AMX backtrace:
[18:16:08] [debug] #0 00048618 in SaveAllObjects ()
[18:16:08] [debug] #1 00069ab4 in public cmd_createobject (playerid=0, params[]=@01651fd0 "20 795") 
[18:16:08] [debug] #2 native CallLocalFunction () from samp-server.exe
[18:16:08] [debug] #3 0003bfa0 in public OnPlayerCommandText (playerid=0, cmdtext[]=@01651f7c "/createobject 20 795")
a problem in SaveAllObjects()?


Re: Anything wrong? - Stinged - 07.09.2016

Yes, please post that function.


Re: Anything wrong? - BrianS123 - 07.09.2016

SOLVED.


Re: Anything wrong? - Konstantinos - 07.09.2016

Post the full reports from crashdetect because you did not post about what index it tries to access element. You did not compile with debug info as Stinged suggested as well.

EDIT: Okay, you got it fixed.