help on dcmd that doesn't work well
#1

I'm trying doing the command it shows the format : /gedit [option] [gateid]
When im just doing /gedit it shows the format, when im doing Example: /gedit speed it shows the full format too,
When im doing Example: /gedit speed 1 , ITS still showing the full format.
Basically the command wont let me continue after telling it the option and gateid.. this gedit raped from iRage original code, it works on zGaming, but not in United Role Play, anyone knows why?

Under public OnPlayerCommandText(playerid, cmdtext[])
Код:
dcmd(gedit, 5, cmdtext);
Top Script
Код:
// Gates
// gedit: object - closed - opened - speed - password
new gEdit[MAX_PLAYERS]; // 1 = closed | 2 = opened
new gEditID[MAX_PLAYERS]; // Object's ID
new Float:gPos[MAX_PLAYERS][3];
new Float:gRot[MAX_PLAYERS][3];
Under public OnPlayerConnect(playerid)
Код:
gEdit[playerid] = 0; gEditID[playerid] = 0;
And public OnPlayerEditDynamicObject is implemented, so gedit can move the gate since 0.3e object editor.

Full dcmd_gedit
Код:
dcmd_gedit(playerid, params[])
{
	new string[128], idx;
	if(!IsPlayerConnected(playerid)) return SendClientMessage(playerid, COLOR_GREY, "You need to login first before using any command.");
	if(!IsPlayerAdmin(playerid)) return SendClientMessageToAll(COLOR_GREY, "You are authorized to use this command.");
 	if(sscanf(params, "s[128]", params))
	{
		SendClientMessage(playerid, COLOR_WHITE, "USAGE: /gedit [option] [gateid]");
		SendClientMessage(playerid, COLOR_GREY, "OPTIONS: object | close | open | speed | password");
		return 1;
	}
	if(!strcmp(params, "object", true))
	{
	    new object;
	    if(sscanf(params, "s[128]ii", params, idx, object)) return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /gedit object [gateid] [objectid]");
        if(!GateInfo2[idx][gModel]) return SendClientMessage(playerid, COLOR_GREY, "Invalid gate id.");
        if(object == 0)
		{
			format(string, sizeof(string), "%d", object);
			return 1;
		}
		GateInfo2[idx][gModel] = object;
		DestroyDynamicObject(GateInfo2[idx][gGate]);
		GateInfo2[idx][gGate] = CreateDynamicObject(GateInfo2[idx][gModel], GateInfo2[idx][gCX], GateInfo2[idx][gCY], GateInfo2[idx][gCZ], GateInfo2[idx][gCRX], GateInfo2[idx][gCRY], GateInfo2[idx][gCRZ]);
	    format(string, sizeof(string), " You have set gate ID %d's object ID to %d.", idx, object);
	    SendClientMessage(playerid, COLOR_WHITE, string);
	}
	else if(!strcmp(params, "close", true, 5))
	{
	    if(sscanf(params, "s[128]i", params, idx)) return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /gedit position [gateid]");
        if(!GateInfo2[idx][gModel]) return SendClientMessage(playerid, COLOR_GREY, "Invalid gate id.");
		gEdit[playerid] = 1;
		gEditID[playerid] = idx;
		GetDynamicObjectPos(GateInfo2[idx][gGate], gPos[playerid][0], gPos[playerid][1], gPos[playerid][2]);
		GetDynamicObjectRot(GateInfo2[idx][gGate], gRot[playerid][0], gRot[playerid][1], gRot[playerid][2]);
		EditDynamicObject(playerid, GateInfo2[idx][gGate]);
	    format(string, sizeof(string), " You are now editing gate ID %d's closing position.", idx);
	    SendClientMessage(playerid, COLOR_WHITE, string);
	}
	else if(!strcmp(params, "open", true, 4))
	{
	    if(sscanf(params, "s[128]i", params, idx)) return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /gedit open [gateid]");
        if(!GateInfo2[idx][gModel]) return SendClientMessage(playerid, COLOR_GREY, "Invalid gate id.");
		gEdit[playerid] = 2;
		gEditID[playerid] = idx;
		GetDynamicObjectPos(GateInfo2[idx][gGate], gPos[playerid][0], gPos[playerid][1], gPos[playerid][2]);
		GetDynamicObjectRot(GateInfo2[idx][gGate], gRot[playerid][0], gRot[playerid][1], gRot[playerid][2]);
		EditDynamicObject(playerid, GateInfo2[idx][gGate]);
	    format(string, sizeof(string), " You are now editing gate ID %d's opening position.", idx);
	    SendClientMessage(playerid, COLOR_WHITE, string);
	}
	else if(!strcmp(params, "speed", true, 5))
	{
	    new Float:speed;
	    if(sscanf(params, "s[128]if", params, idx, speed)) return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /gedit open [gateid] [speed]");
        if(!GateInfo2[idx][gModel]) return SendClientMessage(playerid, COLOR_GREY, "Invalid gate id.");
		GateInfo2[idx][gSpeed] = speed;
	    format(string, sizeof(string), " You have set gate ID %d's moving speed to %f.", idx, speed);
	    SendClientMessage(playerid, COLOR_WHITE, string);
	}
	else if(!strcmp(params, "password", true, 8))
	{
	    new password[256];
	    if(sscanf(params, "s[128]is[256]", params, idx, password)) return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /gedit open [gateid] [password]");
        if(!GateInfo2[idx][gModel]) return SendClientMessage(playerid, COLOR_GREY, "Invalid gate id.");
		format(GateInfo2[idx][gPassword], 256, "%s", password);
	    format(string, sizeof(string), " You have set gate ID %d's password to {FF6347}%s", idx, password);
	    SendClientMessage(playerid, COLOR_WHITE, string);
	}
	return 1;
}
I would +rep and be thankful for help
Reply
#2

bump* please help
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)