19.03.2010, 02:21
does anyone know of a way to optimize this code or a better way?
Code:
dcmd_setp(playerid, params[])
{
new id;
new Float:x, Float:y, Float:z, Float:tempf1, Float:rotz;
new strig[200], cmd1[4], temp1[200], temp2[200];
if(dUserINT(PlayerName(playerid)).("accesslevel") >=2)
{
if(sscanf(params, "iz", id, temp1)) return SystemMsg(playerid, "USAGE: /set <p (player) / o (object)> <object> <args>");
else
{
if(IsPlayerConnected(id))
{
GetPlayerPos(id, x, y, z);
GetPlayerFacingAngle(id, rotz);
loop1:
if(!sscanf(temp1, "sfz", cmd1, tempf1, temp2))
{
if(!strcmp(cmd1, "x", true, 1))
x = tempf1;
if(!strcmp(cmd1, "y", true, 1))
y = tempf1;
if(!strcmp(cmd1, "z", true, 1))
z = tempf1;
if(!strcmp(cmd1, "z", true, 1))
rotz = tempf1;
if(strlen(temp2) > 0)
{
temp1 = temp2;
format(temp2, sizeof(temp2),"");
goto loop1;
}
}
SetPlayerPos(id, x, y, z);
SetPlayerFacingAngle(id, rotz);
format(strig, sizeof(strig),"id:%i loc: x %f y %f z %f angle %f" , id, x,y,z,rotz);
return SystemMsg(playerid, strig);
}
else
return SystemMsg(playerid, "USAGE: /set <p (player) / o (object)> <object> <args>");
}
}
else
return SystemMsg(playerid, "You do not have access to this command.");
}

