17.07.2014, 06:53
Hello i want a command to create door ,i already got command how to create gate and i want command /createdoor which when i do /door it open the door or close it ,here is the code from PWN of the gates ,
pawn Код:
#define MAX_GATES 1001
enum gateInfo
{
gGate,
Text3D:gText,
gModel,
gFaction,
Float:gCX,
Float:gCY,
Float:gCZ,
Float:gSpeed,
gStatus
}
new GateInfo[MAX_GATES][gateInfo];
enum _gates
{
gID,
gFactionID,
gModelID,
gOpen,
Float:closeX, Float:closeY, Float:closeZ, Float: rotX, Float: rotY, Float: rotZ,
Float:openX, Float:openY, Float:openZ, Float: openrotX, Float: openrotY, Float: openrotZ,
}
stock LoadGates()
{
new file[64];
for(new t=0; t<=MAX_GATES; t++)
{
format(file,sizeof(file),"gates/gate%d.txt",t);
new Float: X, Float: Y, Float: Z;
X = dini_Float(file,"floatx");
Y = dini_Float(file,"floaty");
Z = dini_Float(file,"floatz");
new F = dini_Int(file,"factionid");
new GID = dini_Int(file,"gateid");
if(dini_Exists(file))
{
GateInfo[t][gModel] = 980;
GateInfo[t][gFaction] = F;
GateInfo[t][gCX] = X;
GateInfo[t][gCY] = Y;
GateInfo[t][gCZ] = Z;
GateInfo[t][gSpeed] = 5;
new string[256];
format(string, sizeof(string), ".::Gate %d::.\nCmd: /fgate\nFaction Owner: %d",t,GateInfo[t][gFaction]);
GateInfo[GID][gGate] = CreateDynamicObject(980, X, Y, Z-1, 0, 0, dini_Float(file,"facingangle"));
GateInfo[t][gText] = CreateDynamic3DTextLabel(string, 0xFFFFFFFF, GateInfo[t][gCX], GateInfo[t][gCY], GateInfo[t][gCZ], 10);
GateInfo[t][gStatus] = 0;
}
}
print("Gates loaded successfully.");
return 1;
}
stock CreateNewGate(hid)
{
new file[64];
format(file,sizeof(file),"gates/gate%d.txt",hid);
new Float: X, Float: Y, Float: Z;
X = dini_Float(file,"floatx");
Y = dini_Float(file,"floaty");
Z = dini_Float(file,"floatz");
new F = dini_Int(file,"factionid");
if(dini_Exists(file))
{
GateInfo[hid][gModel] = 980;
GateInfo[hid][gFaction] = F;
GateInfo[hid][gCX] = X;
GateInfo[hid][gCY] = Y;
GateInfo[hid][gCZ] = Z;
GateInfo[hid][gSpeed] = 5;
new string[256];
format(string, sizeof(string), ".::Gate %d::.\nCmd: /fgate\nFaction Owner: %d",hid,GateInfo[hid][gFaction]);
GateInfo[hid][gGate] = CreateDynamicObject(980, dini_Float(file,"floatx"), dini_Float(file,"floaty"), dini_Float(file,"floatz")-1, 0, 0, dini_Float(file,"facingangle"));
GateInfo[hid][gText] = CreateDynamic3DTextLabel(string, 0xFFFFFFFF, GateInfo[hid][gCX], GateInfo[hid][gCY], GateInfo[hid][gCZ], 10);
GateInfo[hid][gStatus] = 0;
}
print("Gates loaded successfully.");
return 1;
}
stock ReturnNextUnusedGate()
{
new hf[64];
for(new h=0; h<=MAX_GATES; h++)
{
format(hf,sizeof(hf),"gates/gate%d.txt",h);
if(dini_Exists(hf)) continue;
return h;
}
return -1;
}
COMMAND:creategate(playerid, params[])
{
new id;
if(PlayerInfo[playerid][power] < 9) return SendClientError(playerid, CANT_USE_CMD);
if( sscanf ( params, "d", id)) return SCP(playerid, "[FACTION ID]");
new hid=ReturnNextUnusedGate();
SendClientMSG(playerid,COLOR_GREY, "Gate [ID: %d] [MODEL: %d] [FACTION ID: %d].",hid,id);
new hf[64];
new Float: X, Float: Y, Float: Z, Float: A;
GetPlayerPos(playerid,X,Y,Z);
GetPlayerFacingAngle(playerid,A);
format(hf,sizeof(hf),"gates/gate%d.txt",hid);
if(!dini_Exists(hf))
{
dini_Create(hf);
dini_IntSet(hf,"gateid",hid);
dini_IntSet(hf,"factionid",id);
dini_FloatSet(hf,"floatx",X);
dini_FloatSet(hf,"floaty",Y);
dini_FloatSet(hf,"floatz",Z);
dini_FloatSet(hf,"facingangle",A);
CreateNewGate(hid);
return 1;
}
return 1;
}
COMMAND:fgate(playerid, params[])
{
for(new h=0; h<=MAX_GATES; h++)
{
if(GateInfo[h][gModel] && IsPlayerInRangeOfPoint(playerid, 8, GateInfo[h][gCX], GateInfo[h][gCY], GateInfo[h][gCZ]))
if(PlayerInfo[playerid][playerteam]==GateInfo[h][gFaction])
{
if(!GateInfo[h][gStatus])
{
MoveDynamicObject(GateInfo[h][gGate], GateInfo[h][gCX], GateInfo[h][gCY], GateInfo[h][gCZ]-10, GateInfo[h][gSpeed]);
GateInfo[h][gStatus]=1;
SendClientInfo(playerid, "Done, Good day ! ");
}
else
{
MoveDynamicObject(GateInfo[h][gGate], GateInfo[h][gCX], GateInfo[h][gCY], GateInfo[h][gCZ]-1, GateInfo[h][gSpeed]);
GateInfo[h][gStatus]=0;
SendClientInfo(playerid, "Done, Good day ! ");
}
return 1;
}
}
return 1;
}