23.08.2017, 06:48
(
Последний раз редактировалось Exhibit; 23.08.2017 в 14:34.
)
I have a Dynamic Gates System which works fine when I assign the gate to a faction but it doesn't work if I assign it to a player.
Please help me, I would give him +REP.
and here is the command to assign the gate to a faction if you need it.
Please help me, I would give him +REP.
PHP код:
//This is the command to open the gate.
CMD:gate(playerid, params[])
{
// Gates
new done, str[265], name[MAX_PLAYER_NAME], giveplayerid;
GetPlayerName(playerid, name, sizeof(name));
for(new idx=1; idx<MAX_GATES; idx++)
{
new Float:cur[3];
if(GateInfo[idx][gModel])
{
GetDynamicObjectPos(GateInfo[idx][gGate], cur[0], cur[1], cur[2]);
if(IsPlayerInRangeOfPoint(playerid, 8, cur[0], cur[1], cur[2]) || IsPlayerInRangeOfPoint(playerid, 8, GateInfo[idx][gCX], GateInfo[idx][gCY], GateInfo[idx][gCZ]) || IsPlayerInRangeOfPoint(playerid, 8, GateInfo[idx][gOX], GateInfo[idx][gOY], GateInfo[idx][gOZ]))
{
if(GetPVarInt(playerid, "playerorg"))
{
format(str, sizeof(str), "org%d", GetPVarInt(playerid, "playerorg"));
new tmp = dini_Int(AddDirFile(dir_orgfiles, str), "GateOwned");
if(tmp == 0) return SendClientMessage(playerid, COLOR_RED, "You cannot open this gate.");
{
if(!GateInfo[idx][gStatus])
{
GateInfo[idx][gStatus] = 1;
MoveDynamicObject(GateInfo[idx][gGate], GateInfo[idx][gOX], GateInfo[idx][gOY], GateInfo[idx][gOZ], GateInfo[idx][gSpeed], GateInfo[idx][gORX], GateInfo[idx][gORY], GateInfo[idx][gORZ]);
done=1;
break;
}
else
{
GateInfo[idx][gStatus] = 0;
MoveDynamicObject(GateInfo[idx][gGate], GateInfo[idx][gCX], GateInfo[idx][gCY], GateInfo[idx][gCZ], GateInfo[idx][gSpeed], GateInfo[idx][gCRX], GateInfo[idx][gCRY], GateInfo[idx][gCRZ]);
done=1;
break;
}
}
}
giveplayerid = dini_Isset(AddDirFile(dir_userfiles, str), "GateID");
if (giveplayerid == 0) return SendClientMessage2(playerid, COLOR_RED, "Error: You don't own this gate!");
{
if(giveplayerid == 1)
{
GateInfo[idx][gStatus] = 1;
MoveDynamicObject(GateInfo[idx][gGate], GateInfo[idx][gOX], GateInfo[idx][gOY], GateInfo[idx][gOZ], GateInfo[idx][gSpeed], GateInfo[idx][gORX], GateInfo[idx][gORY], GateInfo[idx][gORZ]);
done=1;
break;
}
else
{
GateInfo[idx][gStatus] = 0;
MoveDynamicObject(GateInfo[idx][gGate], GateInfo[idx][gCX], GateInfo[idx][gCY], GateInfo[idx][gCZ], GateInfo[idx][gSpeed], GateInfo[idx][gCRX], GateInfo[idx][gCRY], GateInfo[idx][gCRZ]);
done=1;
break;
}
}
if(strlen(GateInfo[idx][gPassword]))
{
if(sscanf(params, "s[256]", params)) return SendClientMessage(playerid, 0xFFFFFF00, "USAGE: /gate [password]");
if(strcmp(params, GateInfo[idx][gPassword])) return SendClientMessage(playerid, -1, "Invalid gate password.");
if(!GateInfo[idx][gStatus])
{
GateInfo[idx][gStatus] = 1;
MoveDynamicObject(GateInfo[idx][gGate], GateInfo[idx][gOX], GateInfo[idx][gOY], GateInfo[idx][gOZ], GateInfo[idx][gSpeed], GateInfo[idx][gORX], GateInfo[idx][gORY], GateInfo[idx][gORZ]);
done=1;
break;
}
}
}
}
}
if(!done) SendClientMessage(playerid, -1, "You aren't near a gate you can open.");
return 1;
}
PHP код:
The command to assign a gate to a player.
CMD:setgateo(playerid, params[])
{
new idx, str[256], id, string[256], name[MAX_PLAYER_NAME];
if(adlvl[playerid]<6) return 0;
if(sscanf(params, "di",id, idx)) return SendClientMessage(playerid, 0xFFFFFF00, "USAGE: /setgateowner [playerid] [gateid]");
if(!IsPlayerConnected(id)) return SendClientMessage(playerid, COLOR_RED, "ERROR: Invalid Player Id.");
GetPlayerName(id, name, sizeof(name));
if (!dini_Exists(AddDirFile(dir_userfiles, name))) return SendClientMessage2(playerid, COLOR_RED, "Error: Account Doesnt Exist");
if(!GateInfo[idx][gModel]) return SendClientMessage(playerid, -1, "Invalid gate id.");
dini_IntSet(AddDirFile(dir_userfiles, string), "GateID", idx);
format(str, sizeof(str), "You have setted gate %d Owned by %s",idx, name);
SendClientMessage(playerid, 0xFFFFFF00, str);
return 1;
}
PHP код:
//GATE EXTRAS
enum gateInfo
{
gGate,
gModel,
Float:gCX,
Float:gCY,
Float:gCZ,
Float:gCRX,
Float:gCRY,
Float:gCRZ,
Float:gOX,
Float:gOY,
Float:gOZ,
Float:gORX,
Float:gORY,
Float:gORZ,
gPassword[256],
Float:gSpeed,
gStatus
}
new GateInfo[MAX_GATES][gateInfo];
PHP код:
CMD:setogate(playerid, params[])
{
new idx, str[256], id, string[256], tmp[256];
if(adlvl[playerid]<6) return 0;
if(sscanf(params, "di",id, idx)) return SendClientMessage(playerid, 0xFFFFFF00, "USAGE: /setogate [orgid] [gateid]");
format(string, 10, "org%d", id);
if (!dini_Exists(AddDirFile(dir_orgfiles, string)))
{
return SendClientMessage2(playerid, COLOR_RED, "Error: Invalid organization id.");
}
if(!GateInfo[idx][gModel]) return SendClientMessage(playerid, -1, "Invalid gate id.");
dini_IntSet(AddDirFile(dir_orgfiles, string), "GateOwned", idx);
tmp = dini_Get(AddDirFile(dir_orgfiles, string), "name");
format(str, sizeof(str), "You have setted gate %d Owned by org %s",idx, tmp);
SendClientMessage(playerid, 0xFFFFFF00, str);
return 1;
}