[18:26:00] [debug] #0 0074b9a8 in public cmd_editgate
#1

Код:
[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
Код:
		return CallLocalFunction("OnPlayerCommandPerformed", "isi", playerid, cmdtext, CallLocalFunction(funcname, "is", playerid, cmdtext[pos])); //ERROR LINE IN zcmd.inc
Код:
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!
Reply
#2

show us the error too probebly the GateCreated is -1 so it crashs the gamemod
Reply
#3

Quote:
Originally Posted by khRamin78
Посмотреть сообщение
show us the error too probebly the GateCreated is -1 so it crashs the gamemod
Edited post, read
Reply
#4

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

pawn Код:
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);
Reply
#5

Quote:
Originally Posted by Calisthenics
Посмотреть сообщение
Next time, post full logs as the second most important line is missing.

pawn Код:
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?
Код:
for(new i=1;i< MAX_GATES;i++){
Reply
#6

Quote:
Originally Posted by ShadowMortar
Посмотреть сообщение
You mean like this?
Код:
for(new i=1;i< MAX_GATES;i++){
i=0;<MAX_GATES;i++ it will loop trough all max_gates numbers
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)