SA-MP Forums

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

Reply
 
Thread Tools Display Modes
Old 10/11/2018, 09:18 PM   #1
ShadowMortar
Little Clucker
 
Join Date: Jul 2016
Posts: 31
Reputation: 5
Angry [18:26:00] [debug] #0 0074b9a8 in public cmd_editgate

Code:
[18:26:00] [debug] #0 0074b9a8 in public cmd_editgate (playerid=0, params[]=@00d130c8 "create 980") at HIDDEN/.pwn:74867
[18:26:00] [debug] #1 native CallLocalFunction () from samp03svr
[18:26:00] [debug] #2 00002d00 in public OnPlayerCommandText (playerid=0, cmdtext[]=@00d13074 "/editgate create 980") at HIDDEN/zcmd.inc:108
Code:
		return CallLocalFunction("OnPlayerCommandPerformed", "isi", playerid, cmdtext, CallLocalFunction(funcname, "is", playerid, cmdtext[pos])); //ERROR LINE IN zcmd.inc
Code:
CMD:editgate(playerid, params[])
{
	if(PlayerInfo[playerid][pAdmin] >= 4 || PlayerInfo[playerid][pDev] >= 2 || PlayerInfo[playerid][pMapper] == MAPPERRANK_MANAGER)
	{
		new action[24], optional;
		if(!sscanf(params, "s[24]F(0.0)", action, optional))
		{
			if(!strcmp(action,"create",true)){
		    	new objid, tempgid, bool:found = false;
		        if(!sscanf(params, "s[24]i", action, objid)){
		            if(IsAValidGateObject(objid)){
				        //for(new i=1;i<=MAX_GATES;i++){
				        for(new i=0;i <= MAX_GATES;i++){
				            if(Gates[i][GateCreated] == 0){ //ERROR LINE 74867
				                tempgid = i;
								found = true;
				                break;
							}
				        }
				        if(found){
				            new Float:x, Float:y, Float:z, vw, inter;
				            GetPlayerPos(playerid, x, y, z);
				            vw = GetPlayerVirtualWorld(playerid);
				            inter = GetPlayerInterior(playerid);
				            EditingGate[playerid] = tempgid;
				            strmid(sendername, PlayerOOCName(playerid), 0, MAX_PLAYER_NAME);
				            Gates[tempgid][GateBy] = sendername;
				            Gates[tempgid][GateObjectID] = objid;
				            Gates[tempgid][GateX] = x+1;
				            Gates[tempgid][GateY] = y+1;
				            Gates[tempgid][GateZ] = z;
				            Gates[tempgid][GateRotX] = 0;
				            Gates[tempgid][GateRotY] = 0;
				            Gates[tempgid][GateRotZ] = 0;
				            Gates[tempgid][GateVW] = vw;
				            Gates[tempgid][GateINT] = inter;
				            Gates[tempgid][GateStatus] = 0;
				            CreateGate(tempgid);
				            format(str, sizeof(str), "  You have succesfully spawned gate(%d) at your current position.", tempgid);
							SendClientMessage(playerid, COLOR_GRAD1, str);
							format(str, sizeof(str), "{FF0000}AdmWarning{FFFFFF}: %s has spawned gate(%d) at their position.", PlayerOOCName(playerid), tempgid);
							ABroadCast(COLOR_WHITE, str, 1);
						}
						else{
						    SendClientMessage(playerid, COLOR_DARKRED, "ERROR: Max gates reached !");
						}
					}
					else {
					    SendClientMessage(playerid, COLOR_GRAD1, "   Invalid object ID !");
					}
				}
				else{
				    SendClientMessage(playerid, COLOR_WHITE, "USAGE: /editgate create [OBJECTID]");
				}
			}
			else if(!strcmp(action, "id", true))
			{
				new gateid;
				if(!sscanf(params, "s[24]i", action, gateid))
				{
					if(gateid == 0 || gateid > MAX_GATES) return SendClientMessage(playerid, COLOR_GRAD1, "Invalid gate ID.");
					if(Gates[gateid][GateCreated] == 1)
					{
						EditingGate[playerid] = gateid;
						format(str, sizeof(str), "You are now editing gate(%d).", EditingGate[playerid]);
						SendClientMessage(playerid, COLOR_GRAD1, str);
					}
					else
					{
						SendClientMessage(playerid, COLOR_GRAD1, "Invalid gate ID.");
					}
				}
				else
				{
					SendClientMessage(playerid, COLOR_GREY, "{00BFFF}Usage:{FFFFFF} /editgate id [GATEID]");
				}
			}
	 		else if(!strcmp(action, "faction", true))
			{
				if(EditingGate[playerid] != 0)
				{
				    new
				        faction;
					if(sscanf(params, "s[24]i", action, faction))
					    return SendClientMessage(playerid, COLOR_GREY, "{00BFFF}Usage:{FFFFFF} /editgate [faction id]");

					if(!(faction > -1))
						return SendClientMessage(playerid, COLOR_GREY, "Invalid faction ID.");

	                Gates[EditingGate[playerid]][Faction] = faction;

	                format(str, sizeof(str), "You have successfully changed gate(%d)'s faction to %d.", EditingGate[playerid], faction);
				    SendClientMessage(playerid, COLOR_GREY, str);
				}
			}
			else if(!strcmp(action, "group", true))
			{
				if(EditingGate[playerid] != 0)
				{
				    new
				        group;
					if(sscanf(params, "s[24]i", action, group))
					    return SendClientMessage(playerid, COLOR_GREY, "{00BFFF}Usage:{FFFFFF} /editgate [faction id]");

					if(!(group > -1))
						return SendClientMessage(playerid, COLOR_GREY, "Invalid faction ID.");

	                Gates[EditingGate[playerid]][Group] = group;

	                format(str, sizeof(str), "You have successfully changed gate(%d)'s faction to %d.", EditingGate[playerid], group);
				    SendClientMessage(playerid, COLOR_GREY, str);
				}
			}
			else if(!strcmp(action, "object", true))
			{
				if(EditingGate[playerid] != 0)
				{
					new objid;
					if(!sscanf(params, "s[24]i", action, objid))
					{
						if(IsAValidGateObject(objid))
						{
							DestroyDynamicObject(Gates[EditingGate[playerid]][GateObject]);
							Gates[EditingGate[playerid]][GateObject] = 0;
							Gates[EditingGate[playerid]][GateObjectID] = objid;
							CreateGate(EditingGate[playerid]);
							format(str, sizeof(str), "You have succesfully changed gate(%d)'s object to %d.", EditingGate[playerid], objid);
							SendClientMessage(playerid, COLOR_GRAD1, str);
						}
						else
						{
							SendClientMessage(playerid, COLOR_GRAD1, "Invalid object ID.");
						}
					}
					else
					{
						SendClientMessage(playerid, COLOR_GREY, "{00BFFF}Usage:{FFFFFF} /editgate object [OBJECTID]");
					}
				}
				else
				{
					SendClientMessage(playerid, COLOR_WHITE, "You are not editing any gate.");
				}
			}
			else if(!strcmp(action, "position", true))
			{
				if(EditingGate[playerid] != 0)
				{
					GateAction[playerid] = EDITING_GATE_POSITION;
					EditDynamicObject(playerid, Gates[EditingGate[playerid]][GateObject]);
					format(str, sizeof(str), "You are now editing gate(%d)'s position.", EditingGate[playerid]);
					SendClientMessage(playerid, COLOR_GRAD1, str);
				}
				else
				{
					SendClientMessage(playerid, COLOR_GRAD1, "You are not editing any gate.");
				}
			}
			else if(!strcmp(action, "oposition", true))
			{
				if(EditingGate[playerid] != 0)
				{
					GateAction[playerid] = EDITING_GATE_OPOSITION;
					EditDynamicObject(playerid, Gates[EditingGate[playerid]][GateObject]);
					format(str, sizeof(str), "You are now editing gate(%d)'s opened position.", EditingGate[playerid]);
					SendClientMessage(playerid, COLOR_GRAD1, str);
				}
				else
				{
					SendClientMessage(playerid, COLOR_GRAD1, "You are not editing any gate.");
				}
			}
			else if(!strcmp(action, "speed", true))
			{
				if(EditingGate[playerid] != 0)
				{
					new Float:newspeed;
					if(!sscanf(params, "s[24]f", action, newspeed))
					{
						if(newspeed < 0.001 || newspeed > 10) return SendClientMessage(playerid, COLOR_GRAD1, "Speed must be between 0.001 or 10 seconds per unit.");
						Gates[EditingGate[playerid]][GateSpeed] = newspeed;
						format(str, sizeof(str), "Gate(%d)'s Speed was succesfully adjust to %f seconds/unit.", EditingGate[playerid], newspeed);
						SendClientMessage(playerid, COLOR_GRAD1, str);
					}
					else
					{
						SendClientMessage(playerid, COLOR_GREY, "{00BFFF}Usage:{FFFFFF} /editgate speed [NEWSPEED(Seconds/unit)]");
					}
				}
				else
				{
					SendClientMessage(playerid, COLOR_GRAD1, "You are not editing any gate.");
				}
			}
			else if(!strcmp(action, "radius", true))
			{
				if(EditingGate[playerid] != 0)
				{
					new Float:newradii;
					if(!sscanf(params, "s[24]f", action, newradii))
					{
						if(newradii < 1 || newradii > 15) return SendClientMessage(playerid, COLOR_GRAD1, "Radius must be between 1 or 15 units.");
						Gates[EditingGate[playerid]][GateRadius] = newradii;
						format(str, sizeof(str), "Gate(%d)'s Radius was succesfully adjust to %f units.", EditingGate[playerid], newradii);
						SendClientMessage(playerid, COLOR_GRAD1, str);
					}
					else
					{
						SendClientMessage(playerid, COLOR_GREY, "{00BFFF}Usage:{FFFFFF} /editgate radius [NEWRADIUS(in units)]");
					}
				}
				else
				{
					SendClientMessage(playerid, COLOR_GRAD1, "You are not editing any gate.");
				}
			}
			else if(!strcmp(action, "houseid", true))
			{
				if(EditingGate[playerid] != 0)
				{
					new hid;
					if(!sscanf(params, "s[24]i", action, hid))
					{
						if(HouseInfo[hid][hCreated] == 1)
						{
							Gates[EditingGate[playerid]][GateHouseID] = HouseInfo[hid][hSQLID];
							format(str, sizeof(str), "Gate(%d) was succesfully connected to house %i.", EditingGate[playerid], hid);
							SendClientMessage(playerid, COLOR_GRAD1, str);
						}
						else
						{
							SendClientMessage(playerid, COLOR_GRAD1, "Invalid house ID.");
						}
					}
					else
					{
						SendClientMessage(playerid, COLOR_GREY, "{00BFFF}Usage:{FFFFFF} /editgate houseid [HOUSEID(to connect the gate to)]");
					}
				}
				else
				{
					SendClientMessage(playerid, COLOR_GRAD1, "You are not editing any gate.");
				}
			}
			else if(!strcmp(action, "delete", true))
			{
				if(EditingGate[playerid] != 0)
				{
					DestroyDynamicObject(Gates[EditingGate[playerid]][GateObject]);
					Gates[EditingGate[playerid]][GateObject] = 0;
					strmid(Gates[EditingGate[playerid]][GateBy], "", 0, strlen("None"), 255);
					Gates[EditingGate[playerid]][GateCreated] = 0;
					Gates[EditingGate[playerid]][GateObjectID] = 0;
					Gates[EditingGate[playerid]][GateX] = 0;
					Gates[EditingGate[playerid]][GateY] = 0;
					Gates[EditingGate[playerid]][GateZ] = 0;
					Gates[EditingGate[playerid]][GateRotX] = 0;
					Gates[EditingGate[playerid]][GateRotY] = 0;
					Gates[EditingGate[playerid]][GateRotZ] = 0;
					Gates[EditingGate[playerid]][GateVW] = 0;
					Gates[EditingGate[playerid]][GateINT] = 0;
					Gates[EditingGate[playerid]][MveGateX] = 0;
					Gates[EditingGate[playerid]][MveGateX] = 0;
					Gates[EditingGate[playerid]][MveGateX] = 0;
					Gates[EditingGate[playerid]][GateSpeed] = 0;
					Gates[EditingGate[playerid]][GateRadius] = 0;
					Gates[EditingGate[playerid]][GateHouseID] = 0;
					Gates[EditingGate[playerid]][GateStatus] = 0;
					format(str, sizeof(str), "You have deleted gate(%d).", EditingGate[playerid]);
					SendClientMessage(playerid, COLOR_GRAD1, str);
					format(str, sizeof(str), "{FF0000}AdmWarning{FFFFFF}: %s has deleted gate(%d).", PlayerICName(playerid), EditingGate[playerid]);
					ABroadCast(COLOR_WHITE, str, 1);
					EditingGate[playerid] = 0;
				}
				else
				{
					SendClientMessage(playerid, COLOR_GRAD1, "You are not editing any gate.");
				}
			}
			else if(!strcmp(action, "reload", true))
			{
				if(EditingGate[playerid] != 0)
				{
					new gid = EditingGate[playerid];
					DestroyDynamicObject(Gates[gid][GateObject]);
					Gates[gid][GateObject] = CreateDynamicObject(Gates[gid][GateObjectID], Gates[gid][GateX], Gates[gid][GateY], Gates[gid][GateZ], Gates[gid][GateRotX], Gates[gid][GateRotY], Gates[gid][GateRotZ], Gates[gid][GateVW], Gates[gid][GateINT]);
					format(str, sizeof(str), "You have reloaded gate(%d).", EditingGate[playerid]);
					SendClientMessage(playerid, COLOR_GRAD1, str);
					format(str, sizeof(str), "{FF0000}AdmWarning{FFFFFF}: %s has reloaded gate(%d).", PlayerICName(playerid), EditingGate[playerid]);
					ABroadCast(COLOR_WHITE, str, 1);
					EditingGate[playerid] = 0;
				}
				else
				{
					SendClientMessage(playerid, COLOR_GRAD1, "You are not editing any gate.");
				}
			}
			else if(!strcmp(action, "stop", true))
			{
				if(EditingGate[playerid] != 0)
				{
					SendClientMessage(playerid, COLOR_GRAD1, "Editing progress was ended.");
					EditingGate[playerid] = 0;
				}
				else
				{
					SendClientMessage(playerid, COLOR_GRAD1, "You are not editing any gate.");
				}
			}
			else
			{
				SendClientMessage(playerid, COLOR_WHITE, "Invalid action.");
			}
		}
		else
		{
			SendClientMessage(playerid, COLOR_GREY, "{00BFFF}Usage:{FFFFFF} /editgate [action]");
			SendClientMessage(playerid, COLOR_GREY, "Available actions: create, id, object, position, oposition, speed, houseid, radius, delete, stop, reload");
			SendClientMessage(playerid, COLOR_GREY, "Available actions: faction");
		}
	}
	else
	{
		AdmErrorMsg;
	}
	return 1;
}
NOTE: No errors in script!
ShadowMortar is online now   Reply With Quote
Old 10/11/2018, 09:25 PM   #2
khRamin78
Huge Clucker
 
khRamin78's Avatar
 
Join Date: Jun 2015
Posts: 243
Reputation: 19
Default Re: [18:26:00] [debug] #0 0074b9a8 in public cmd_editgate

show us the error too probebly the GateCreated is -1 so it crashs the gamemod
__________________
My Work's :
khRamin78 is offline   Reply With Quote
Old 10/11/2018, 09:44 PM   #3
ShadowMortar
Little Clucker
 
Join Date: Jul 2016
Posts: 31
Reputation: 5
Default Re: [18:26:00] [debug] #0 0074b9a8 in public cmd_editgate

Quote:
Originally Posted by khRamin78 View Post
show us the error too probebly the GateCreated is -1 so it crashs the gamemod
Edited post, read
ShadowMortar is online now   Reply With Quote
Old 10/11/2018, 10:01 PM   #4
Calisthenics
Huge Clucker
 
Join Date: May 2018
Posts: 404
Reputation: 69
Default Re: [18:26:00] [debug] #0 0074b9a8 in public cmd_editgate

Next time, post full logs as the second most important line is missing.

pawn Code:
for(new i=0;i <= MAX_GATES;i++){
Out of bounds (run time error 4). The correct would be i < MAX_GATES; but use `sizeof` operator as it is the best choice. It becomes i < sizeof (Gates);
Calisthenics is offline   Reply With Quote
Old 10/11/2018, 10:24 PM   #5
ShadowMortar
Little Clucker
 
Join Date: Jul 2016
Posts: 31
Reputation: 5
Default Re: [18:26:00] [debug] #0 0074b9a8 in public cmd_editgate

Quote:
Originally Posted by Calisthenics View Post
Next time, post full logs as the second most important line is missing.

pawn Code:
for(new i=0;i <= MAX_GATES;i++){
Out of bounds (run time error 4). The correct would be i < MAX_GATES; but use `sizeof` operator as it is the best choice. It becomes i < sizeof (Gates);
You mean like this?
Code:
for(new i=1;i< MAX_GATES;i++){
ShadowMortar is online now   Reply With Quote
Old 11/11/2018, 08:08 AM   #6
khRamin78
Huge Clucker
 
khRamin78's Avatar
 
Join Date: Jun 2015
Posts: 243
Reputation: 19
Default Re: [18:26:00] [debug] #0 0074b9a8 in public cmd_editgate

Quote:
Originally Posted by ShadowMortar View Post
You mean like this?
Code:
for(new i=1;i< MAX_GATES;i++){
i=0;<MAX_GATES;i++ it will loop trough all max_gates numbers
__________________
My Work's :
khRamin78 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
Problem [DEBUG] public OnVehicleSpawn Lloyde Scripting Help 0 06/11/2016 06:30 AM
Which ? (PAWN Public ws New Public) ProRakNet Scripting Help 8 26/04/2016 10:19 AM
[Help] [debug] #0 002142b4 in public @_yCexit (0, 32741176, 0) from XGTA.amx Imissziu Scripting Help 2 13/11/2015 11:20 AM
[Debug] Error public PryX0G3n Scripting Help 2 29/09/2012 11:33 PM


All times are GMT. The time now is 06:02 PM.


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