24.09.2017, 15:41
PHP код:
CMD:gate(playerid, params[])
{
// Gates
new done, str[265], name[MAX_PLAYER_NAME];
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(GateInfo[idx][gOOwned] != 0)
{
if(GetPVarInt(playerid, "playerorg") != 0)
{
format(str, sizeof(str), "org%d", GetPVarInt(playerid, "playerorg"));
new tmp = dini_Int(AddDirFile(dir_orgfiles, str), "GateOwned1");
new tmp2 = dini_Int(AddDirFile(dir_orgfiles, str), "GateOwned2");
new tmp3 = dini_Int(AddDirFile(dir_orgfiles, str), "GateOwned3");
if((tmp == idx) || (tmp2 == idx) || (tmp3 == idx))
{
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;
}
}
else {
format(str, sizeof(str), "This gate has been assigned to '%s' you cant open it.", GateInfo[idx][gOOwned]);
SendClientMessage(playerid, COLOR_WHITE, str);
done = 1;
break;
}
}
else {
format(str, sizeof(str), "This gate has been assigned to '%s' you cant open it.", GateInfo[idx][gOOwned]);
SendClientMessage(playerid, COLOR_WHITE, str);
done = 1;
break;
}
}
if(dini_Int(AddDirFile(dir_userfiles, name), "GateID") == idx)
{
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;
}
}
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;
}
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;
}
}
else
{
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;
}
}
}
}
}
if(!done) SendClientMessage(playerid, -1, "You aren't near a gate you can open.");
return 1;
}
PHP код:
CMD:setgateo(playerid, params[])
{
return cmd_setgateowner(playerid, params);
}
CMD:setgateowner(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_Unset(AddDirFile(dir_userfiles, string), "GateID");
dini_IntSet(AddDirFile(dir_userfiles, string), "GateID", idx);
format(GateInfo[idx][gOwner], 256, "%s", name);
format(str, sizeof(str), "You have setted gate %d Owned by %s",idx, name);
SendClientMessage(playerid, 0xFFFFFF00, str);
SaveGates();
return 1;
}
PHP код:
CMD:mygate(playerid, params[])
{
new done, name[MAX_PLAYER_NAME];
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]))
{
new gc = dini_Int(AddDirFile(dir_userfiles, name), "GateID");
if(gc == 0) return SendClientMessage(playerid, COLOR_RED, "Error: This Gate doesn't belong to you.");
{
if(gc == idx)
{
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;
}
}
}
}
}
}
if(!done) SendClientMessage(playerid, COLOR_WHITE, "Error: You aren't near a gate you can open.");
return 1;
}