Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // === < Includes > === //
- #include <a_samp>
- #include <DOF2>
- #include <streamer>
- // === < Defines > === //
- #define MAX_GATES 100
- #define function%0(%1) forward%0(%1);public%0(%1)
- #define SCM SendClientMessage
- #define SCMToAll SendClientMessageToAll
- #define GatePath "Clans/Gates/%d.txt"
- // === < Enums > === //
- enum gateInfo
- {
- gGate,
- gClanGate[90],
- 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,
- Float:gSpeed,
- gStatus
- };
- // === < Vars > === //
- new gInfo[MAX_GATES][gateInfo];
- new gEdit[MAX_PLAYERS];
- new gEditID[MAX_PLAYERS];
- new Float:gPos[MAX_PLAYERS][3];
- new Float:gRot[MAX_PLAYERS][3];
- public OnGameModeInit()
- {
- return 1;
- }
- public OnGameModeExit()
- {
- DOF2_Exit();
- return 1;
- }
- public OnPlayerCommandText(playerid, cmdtext[])
- {
- new tmp1[256], tmp2[256], idx;
- if(!strcmp(cmdtext, "/CreateGate", true) || !strcmp(cmdtext, "/cGate", true))
- {
- new object;
- if(!IsPlayerAdmin(playerid)) return 0;
- tmp1 = strtok(cmdtext, idx);
- if(!strlen(tmp1)) return SCM(playerid, -1, "[Usage]: /CreateGate(/cGate) <objectid>");
- for(new i = 0; i < MAX_GATES; i++)
- {
- if(!gInfo[i][gModel])
- {
- GetPlayerPos(playerid, gInfo[i][gCX], gInfo[i][gCY], gInfo[i][gCZ]);
- gInfo[i][gModel] = object;
- gInfo[i][gCX] = gInfo[i][gCX] + 2;
- gInfo[i][gCY] = gInfo[i][gCY] + 2;
- gInfo[i][gCRX] = 0;
- gInfo[i][gCRY] = 0;
- gInfo[i][gCRZ] = 0;
- GetPlayerPos(playerid, gInfo[i][gOX], gInfo[i][gOY], gInfo[i][gOZ]);
- gInfo[i][gOX] = gInfo[i][gOX] + 2;
- gInfo[i][gOY] = gInfo[i][gOY] + 2;
- gInfo[i][gORX] = 0;
- gInfo[i][gORY] = 0;
- gInfo[i][gORZ] = 0;
- gInfo[i][gSpeed] = 2;
- gInfo[i][gStatus] = 0;
- // Creating
- gInfo[i][gGate] = CreateDynamicObject(gInfo[i][gModel], gInfo[i][gCX], gInfo[i][gCY], gInfo[i][gCZ], gInfo[i][gCRX], gInfo[i][gCRY], gInfo[i][gCRZ]);
- i = MAX_GATES;
- }
- }
- return 1;
- }
- if(!strcmp(cmdtext, "/EditGate", true) || !strcmp(cmdtext, "/eGate", true))
- {
- if(!IsPlayerAdmin(playerid)) return 0;
- tmp1 = strtok(cmdtext, idx);
- tmp2 = strtok(cmdtext, idx);
- if(!strlen(tmp1) || !strlen(tmp2))
- {
- SCM(playerid, -1, "[Usage]: /EditGate(/eGate) [option] [gateid]");
- SCM(playerid, -1, "Options: Close - Open - Speed");
- return 1;
- }
- for(new i = 0; i < MAX_GATES; i++)
- {
- new tmp3[256];
- if(!strcmp(tmp2, "Close", true))
- {
- tmp3 = strtok(cmdtext, idx);
- if(!strlen(tmp1)) return SendClientMessage(playerid, -1, "[Usage]: /EditGate position [gateid]");
- if(!gInfo[i][gModel]) return SendClientMessage(playerid, 0xFF0000AA, "[Error]: àééãé ùâåé");
- gEdit[playerid] = 1;
- gEditID[playerid] = i;
- GetDynamicObjectPos(gInfo[i][gGate], gPos[playerid][0], gPos[playerid][1], gPos[playerid][2]);
- GetDynamicObjectRot(gInfo[i][gGate], gRot[playerid][0], gRot[playerid][1], gRot[playerid][2]);
- EditDynamicObject(playerid, gInfo[i][gGate]);
- }
- if(!strcmp(tmp2, "Open", true))
- {
- tmp3 = strtok(cmdtext, idx);
- if(!strlen(tmp1)) return SendClientMessage(playerid, -1, "[Usage]: /EditGate position [gateid]");
- if(!gInfo[i][gModel]) return SendClientMessage(playerid, 0xFF0000AA, "[Error]: àééãé ùâåé");
- gEdit[playerid] = 2;
- gEditID[playerid] = i;
- GetDynamicObjectPos(gInfo[i][gGate], gPos[playerid][0], gPos[playerid][1], gPos[playerid][2]);
- GetDynamicObjectRot(gInfo[i][gGate], gRot[playerid][0], gRot[playerid][1], gRot[playerid][2]);
- EditDynamicObject(playerid, gInfo[i][gGate]);
- }
- if(!strcmp(tmp2, "Speed", true))
- {
- new Float:speed, tmp4[256];
- if(!strlen(tmp3) || !strlen(tmp4))
- {
- SendClientMessage(playerid, -1, "[Usage]: /editgate open [gateid] [speed]");
- }
- if(!gInfo[i][gModel]) return SendClientMessage(playerid, 0xFF0000AA, "[Error]: àééãé ùâåé");
- gInfo[i][gSpeed] = speed;
- }
- }
- return 1;
- }
- /* if(!strcmp(cmdtext, "/Open", true))
- {
- new file[38];
- new ClanFile[256];
- format(file, sizeof(file), "Clans/HQ/%d.ini", DOF2_GetInt(ClanFile, "ID"));
- if(DOF2_GetInt(PFile(playerid),"InClan") == 0) return SendClientMessage(playerid,-1,"{FF0000}àéðê á÷ìàï");
- if(!fexist(file)) return SendClientMessage(playerid, -1, "{FF0000}àéï ì÷ìàï ùìê îô÷ãä");
- for(new i = 0; i < MAX_GATES; i++)
- {
- if(gInfo[i][gModel] && IsPlayerInRangeOfPoint(playerid, 7, gInfo[i][gCX], gInfo[i][gCY], gInfo[i][gCZ]))
- {
- if(!gInfo[idx][gStatus])
- {
- gInfo[idx][gStatus] = 1;
- MoveDynamicObject(gInfo[i][gGate], gInfo[i][gOX], gInfo[i][gOY], gInfo[i][gOZ], gInfo[i][gSpeed]);
- SetDynamicObjectRot(gInfo[i][gGate], gInfo[i][gORX], gInfo[i][gORY], gInfo[i][gORZ]);
- }
- i = MAX_GATES;
- }
- }
- return 1;
- }
- if(!strcmp(cmdtext, "/Close", true))
- {
- new file[38];
- new ClanFile[256];
- format(file, sizeof(file), "Clans/HQ/%d.ini", DOF2_GetInt(ClanFile, "ID"));
- if(DOF2_GetInt(PFile(playerid),"InClan") == 0) return SendClientMessage(playerid,-1,"{FF0000}àéðê á÷ìàï");
- if(!fexist(file)) return SendClientMessage(playerid, -1, "{FF0000}àéï ì÷ìàï ùìê îô÷ãä");
- for(new i = 0; i < MAX_GATES; i++)
- {
- if(gInfo[i][gModel] && IsPlayerInRangeOfPoint(playerid, 7, gInfo[i][gCX], gInfo[i][gCY], gInfo[i][gCZ]))
- {
- if(!gInfo[idx][gStatus])
- {
- gInfo[idx][gStatus] = 0;
- MoveDynamicObject(gInfo[i][gGate], gInfo[i][gOX], gInfo[i][gOY], gInfo[i][gOZ], gInfo[i][gSpeed]);
- SetDynamicObjectRot(gInfo[i][gGate], gInfo[i][gORX], gInfo[i][gORY], gInfo[i][gORZ]);
- }
- i = MAX_GATES;
- }
- }
- return 1;
- } */
- if(!strcmp(cmdtext, "/DeleteGate", true) || !strcmp(cmdtext, "/dGate", true))
- {
- new idx2;
- if(!IsPlayerAdmin(playerid)) return 0;
- tmp1 = strtok(cmdtext, idx);
- if(!strlen(tmp1)) return SCM(playerid, -1, "[Usage]: /DeleteGate(/dGate) <gateid>");
- if(!gInfo[idx2][gModel]) return SendClientMessage(playerid, 0xFF0000AA, "[Error]: àééãé ùâåé");
- for(new i = 0; i < MAX_GATES; i++)
- {
- gInfo[i][gModel] = 0;
- gInfo[i][gCX] = 0;
- gInfo[i][gCY] = 0;
- gInfo[i][gCZ] = 0;
- gInfo[i][gCRX] = 0;
- gInfo[i][gCRY] = 0;
- gInfo[i][gCRZ] = 0;
- gInfo[i][gOX] = 0;
- gInfo[i][gOY] = 0;
- gInfo[i][gOZ] = 0;
- gInfo[i][gORX] = 0;
- gInfo[i][gORY] = 0;
- gInfo[i][gORZ] = 0;
- gInfo[i][gSpeed] = 0;
- gInfo[i][gStatus] = 0;
- DestroyDynamicObject(gInfo[i][gGate]);
- }
- }
- return 1;
- }
- //=================================== < Stocks > =============================//
- stock PFile(playerid)
- {
- new string[64];
- format(string,sizeof(string),UserPath,GetName[playerid]);
- return string;
- }
- stock LoadGates()
- {
- new file[35],gateid;
- for(new i = 0; i < MAX_GATES; i++)
- {
- format(file, sizeof(file), "Clans/Gates/%d.ini", i);
- if(fexist(file))
- {
- format(gInfo[i][gClanGate], 90, "%s", DOF2_GetString(file, "ClanName"));
- gInfo[i][gModel] = DOF2_GetInt(SaveGates(), "Model");
- gInfo[i][gCX] = DOF2_GetFloat(SaveGates(), "X");
- gInfo[i][gCY] = DOF2_GetFloat(SaveGates(), "Y");
- gInfo[i][gCZ] = DOF2_GetFloat(SaveGates(), "Z");
- gInfo[i][gCRX] = DOF2_GetFloat(SaveGates(), "RX");
- gInfo[i][gCRY] = DOF2_GetFloat(SaveGates(), "RY");
- gInfo[i][gCRZ] = DOF2_GetFloat(SaveGates(), "RZ");
- gInfo[i][gOX] = DOF2_GetFloat(SaveGates(), "OX");
- gInfo[i][gOY] = DOF2_GetFloat(SaveGates(), "OY");
- gInfo[i][gOZ] = DOF2_GetFloat(SaveGates(), "OZ");
- gInfo[i][gORX] = DOF2_GetFloat(SaveGates(), "ORX");
- gInfo[i][gORY] = DOF2_GetFloat(SaveGates(), "ORY");
- gInfo[i][gORZ] = DOF2_GetFloat(SaveGates(), "ORZ");
- gInfo[i][gSpeed] = DOF2_GetFloat(SaveGates(), "Speed");
- gInfo[i][gStatus] = DOF2_GetInt(SaveGates(), "Status");
- gateid ++;
- }
- }
- printf("ClanFile > Gates: %d", gateid);
- return 1;
- }
- stock strtok(const string[], &index)
- {
- new length = strlen(string);
- while ((index < length) && (string[index] <= ' '))
- {
- index++;
- }
- new offset = index;
- new result[20];
- while ((index < length) && (string[index] > ' ') && ((index - offset) < (sizeof(result) - 1)))
- {
- result[index - offset] = string[index];
- index++;
- }
- result[index - offset] = EOS;
- return result;
- }
- //=================================== < Stocks > =============================//
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement