Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* gPositions - Created by Famalamalam - 19/07/2011
- gPositions is a feature from my developing game-mode, the
- idea was inspired from GamerX's /l feature. Credits go to:
- y_less - sscanf plug-in
- Incognito - Streamer plug-in
- ZeeX - ZCMD
- Creator of Dini
- SA-MP Team
- Myself for creating this awesome shit.
- Profile: http://forum.sa-mp.com/member.php?u=126093
- All rights reserved. You may edit as needed but you shall not re-release
- this script as your own, or otherwise. Then I'd have to hunt you down
- and kill you..... Just kidding >:D .. or am I?
- */
- // Includes
- #include <a_samp>
- #include <zcmd>
- #include <sscanf2>
- #include <streamer>
- #include <Dini>
- // Definitions
- #define MAX_gPOSITIONS 200
- #define gFile_Loc "../gPosition/%i.ini"
- //Colours and things
- #define COL_INDIGO "{8B008B}"
- #define Red 0xFF0000AA
- #define White 0xFFFFFFFF
- #define AREA_MSG 0xA4A4D2FF
- // Arrays & Shit
- new
- gCount,
- gSlots_Left;
- stock GetgSlotsLeft()
- {
- gSlots_Left = MAX_gPOSITIONS - gCount;
- return gSlots_Left;
- }
- enum gPosData
- {
- gFileID,
- gInterior,
- gWorld,
- gvAuth,
- gCPID,
- Float:gX,
- Float:gY,
- Float:gZ,
- gName[128],
- Float:gAngle,
- Text3D:g3DLabel
- };
- new gPosInfo[MAX_gPOSITIONS][gPosData];
- public OnFilterScriptInit()
- {
- print("\n--------------------------------------------------------");
- print(" gPositions script is now running - Created by Famalamalam");
- print("---------------------------------------------------------\n");
- LoadgPosData();
- return 1;
- }
- public OnFilterScriptExit()
- {
- return 1;
- }
- public OnPlayerConnect(playerid)
- {
- SendClientMessage(playerid, White, "This server is using gPositions by Famalamalam.");
- SendClientMessage(playerid, White, "Use the command /g for gPositions.");
- return 1;
- }
- CMD:g(playerid, params[])
- {
- new string[128], FileID;
- if(!sscanf(params, "d", FileID))
- {
- if(FileID > MAX_gPOSITIONS || FileID < 1) return SendClientMessage(playerid, Red, "The gPosition you entered is out of range.");
- format(string, sizeof(string), gFile_Loc, FileID);
- if(dini_Exists(string))
- {
- if(gPosInfo[FileID][gvAuth] == 1 && IsPlayerInAnyVehicle(playerid))
- {
- SetVehiclePos(GetPlayerVehicleID(playerid), gPosInfo[FileID][gX], gPosInfo[FileID][gY], gPosInfo[FileID][gZ]);
- SetVehicleVirtualWorld(GetPlayerVehicleID(playerid), gPosInfo[FileID][gWorld]);
- SetPlayerVirtualWorld(playerid, gPosInfo[FileID][gWorld]);
- SetPlayerInterior(playerid, gPosInfo[FileID][gInterior]);
- LinkVehicleToInterior(GetPlayerVehicleID(playerid), gPosInfo[FileID][gInterior]);
- GameTextForPlayer(playerid, gPosInfo[FileID][gName], 4000, 4);
- format(string, sizeof(string), "You have been teleported to %s[%d]", gPosInfo[FileID][gName], FileID);
- SendClientMessage(playerid, AREA_MSG, string);
- }
- if(gPosInfo[FileID][gvAuth] == 0 && IsPlayerInAnyVehicle(playerid))
- {
- SetPosAndAngle(playerid, gPosInfo[FileID][gX], gPosInfo[FileID][gY], gPosInfo[FileID][gZ], gPosInfo[FileID][gAngle]);
- new vID = GetPlayerVehicleID(playerid);
- RemovePlayerFromVehicle(playerid);
- SetVehicleToRespawn(vID);
- SetPlayerVirtualWorld(playerid, gPosInfo[FileID][gWorld]);
- SetPlayerInterior(playerid, gPosInfo[FileID][gInterior]);
- GameTextForPlayer(playerid, gPosInfo[FileID][gName], 4000, 4);
- format(string, sizeof(string), "You have been teleported to %s[%d]", gPosInfo[FileID][gName], FileID);
- SendClientMessage(playerid, AREA_MSG, string);
- }
- else
- {
- SetPosAndAngle(playerid, gPosInfo[FileID][gX], gPosInfo[FileID][gY], gPosInfo[FileID][gZ], gPosInfo[FileID][gAngle]);
- SetPlayerVirtualWorld(playerid, gPosInfo[FileID][gWorld]);
- SetPlayerInterior(playerid, gPosInfo[FileID][gInterior]);
- GameTextForPlayer(playerid, gPosInfo[FileID][gName], 4000, 4);
- format(string, sizeof(string), "You have been teleported to %s[%d]", gPosInfo[FileID][gName], FileID);
- SendClientMessage(playerid, AREA_MSG, string);
- }
- }
- else
- {
- SendClientMessage(playerid, Red, "That gPosition does not exist, or has not been created yet! [1-200]");
- return 1;
- }
- }
- else
- {
- SendClientMessage(playerid, Red, "USAGE: /g [1-200]");
- return 1;
- }
- return 1;
- }
- CMD:gfillpos(playerid, params[])
- {
- new ID, string[128], name[128], vAuth, gID, Float:X, Float:Y, Float:Z, Float:Angle;
- if(IsPlayerAdmin(playerid))
- {
- if(!sscanf(params, "iis[128]",gID, vAuth, name))
- {
- GetPlayerPos(playerid, X, Y, Z);
- GetPlayerFacingAngle(playerid, Angle);
- new pInterior = GetPlayerInterior(playerid);
- new pWorld = GetPlayerVirtualWorld(playerid);
- format(string,sizeof(string),gFile_Loc,gID);
- if(!dini_Exists(string))
- {
- if(vAuth >=0 && vAuth < 2)
- {
- dini_Create(string);
- dini_Set(string, "Name", name);
- dini_FloatSet(string, "X", X);
- dini_FloatSet(string, "Y", Y);
- dini_FloatSet(string, "Z", Z);
- dini_FloatSet(string, "Angle", Angle);
- dini_IntSet(string, "Interior", pInterior);
- dini_IntSet(string, "World", pWorld);
- dini_IntSet(string, "VehicleAuth", vAuth);
- format(string, sizeof(string), "Refilled gPosition number %d with name %s. VehicleAuth Status: %d gSlots left: %i", ID, name, vAuth, GetgSlotsLeft());
- SendClientMessage(playerid, White, string);
- LoadgPosData();
- }
- else
- {
- SendClientMessage(playerid, Red, "vAuth - Range between 0 & 1. 0 for no access and 1 for authorized access.");
- }
- }
- else
- {
- SendClientMessage(playerid, Red, "ERROR: Selected gPosition is already filled!");
- }
- }
- else
- {
- SendClientMessage(playerid, Red, "USAGE: /gfill [ID 1-200] [vehicles allowed? 0/1] [name]");
- }
- }
- else
- {
- return 0;
- }
- return 1;
- }
- CMD:gcreate(playerid, params[])
- {
- new ID, string[128], name[128], vAuth, Float:X, Float:Y, Float:Z, Float:Angle;
- if(IsPlayerAdmin(playerid))
- {
- new FoundID = 0;
- if(!sscanf(params, "is[128]", vAuth, name))
- {
- GetPlayerPos(playerid, X, Y, Z);
- GetPlayerFacingAngle(playerid, Angle);
- new pInterior = GetPlayerInterior(playerid);
- new pWorld = GetPlayerVirtualWorld(playerid);
- for ( new i = 1; FoundID <= 0 ; i++)
- {
- format(string,sizeof(string),gFile_Loc,i);
- if(!dini_Exists(string))
- {
- ID = i;
- FoundID = 1;
- }
- if( i > MAX_gPOSITIONS )
- {
- return true;
- }
- }
- if(vAuth >=0 && vAuth < 2)
- {
- format(string,sizeof(string),gFile_Loc,ID);
- dini_Create(string);
- dini_Set(string, "Name", name);
- dini_FloatSet(string, "X", X);
- dini_FloatSet(string, "Y", Y);
- dini_FloatSet(string, "Z", Z);
- dini_FloatSet(string, "Angle", Angle);
- dini_IntSet(string, "Interior", pInterior);
- dini_IntSet(string, "World", pWorld);
- dini_IntSet(string, "VehicleAuth", vAuth);
- /*
- gPosInfo[ID][gCPID] = CreateDynamicCP(X, Y, Z, 2, pWorld, pInterior, -1, 50);
- format(string, sizeof(string),"%s\n /g %d",dini_Get(string, "Name"), ID);
- gPosInfo[ID][g3DLabel] = CreateDynamic3DTextLabel(string, AREA_MSG, X, Y, Z+0.4, 50);
- */
- format(string, sizeof(string), "Created gPosition number %d with name %s. Vehicle Auth Status: %d. gSlots left: %i", ID, name, vAuth, GetgSlotsLeft());
- SendClientMessage(playerid, White, string);
- LoadgPosData();
- }
- else
- {
- SendClientMessage(playerid, Red, "vAuth - Range between 0 & 1. 0 for no access and 1 for authorized access.");
- }
- }
- else
- {
- SendClientMessage(playerid, Red, "USAGE: /gcreate [vehicles allowed? 0/1] [name]");
- }
- }
- else
- {
- return 0;
- }
- return 1;
- }
- CMD:gremove(playerid, params[])
- {
- if(IsPlayerAdmin(playerid))
- {
- new string[128], gPosID;
- if(!sscanf(params, "i", gPosID))
- {
- if(gPosID > MAX_gPOSITIONS || gPosID < 1) return SendClientMessage(playerid, Red, "The gPosition you entered is out of range.");
- format(string,sizeof(string),gFile_Loc,gPosInfo[gPosID][gFileID]);
- if(dini_Exists(string))
- {
- dini_Remove(string);
- if(IsValidDynamicCP(gPosInfo[gPosID][gCPID]))
- {
- DestroyDynamicCP(gPosInfo[gPosID][gCPID]); // Destroying exisiting CP's...
- }
- if(IsValidDynamic3DTextLabel(gPosInfo[gPosID][g3DLabel]))
- {
- DestroyDynamic3DTextLabel(gPosInfo[gPosID][g3DLabel]);
- }
- format(string, sizeof(string), ""COL_INDIGO"The gPosition with ID:%i was successfully removed. Don't forget to replace it.", gPosInfo[gPosID][gFileID]);
- SendClientMessage(playerid, White, string);
- gCount --;
- }
- else
- {
- SendClientMessage(playerid, Red, "ERROR: That gPos ID does not exist!");
- return 1;
- }
- }
- else
- {
- SendClientMessage(playerid, Red, "USAGE: /gremove [1-200]");
- }
- }
- else
- {
- return 0;
- }
- return 1;
- }
- forward LoadgPosData();
- public LoadgPosData()
- {
- new string[128];
- for(new i = 1; i < MAX_gPOSITIONS; i++)
- {
- format(string,sizeof(string),gFile_Loc,i);
- if(dini_Exists(string))
- {
- if(IsValidDynamicCP(gPosInfo[i][gCPID]))
- {
- DestroyDynamicCP(gPosInfo[i][gCPID]); // Destroying exisiting CP's...
- }
- if(IsValidDynamic3DTextLabel(gPosInfo[i][g3DLabel]))
- {
- DestroyDynamic3DTextLabel(gPosInfo[i][g3DLabel]);
- }
- gPosInfo[i][gFileID] = i;
- gPosInfo[i][gWorld] = dini_Int(string, "World");
- gPosInfo[i][gInterior] = dini_Int(string, "Interior");
- gPosInfo[i][gX] = dini_Float(string, "X");
- gPosInfo[i][gY] = dini_Float(string, "Y");
- gPosInfo[i][gZ] = dini_Float(string, "Z");
- gPosInfo[i][gAngle] = dini_Float(string, "Angle");
- gPosInfo[i][gvAuth] = dini_Int(string, "VehicleAccess");
- format(gPosInfo[i][gName], 128, dini_Get(string, "Name"));
- //So we can re-create them without getting doubles ... Hopefully.... O_OCountDynamicMapIcons()
- gPosInfo[i][gCPID] = CreateDynamicCP(gPosInfo[i][gX], gPosInfo[i][gY], gPosInfo[i][gZ], 2, gPosInfo[i][gWorld], gPosInfo[i][gInterior], -1, 50);
- format(string, sizeof(string),"%s\n Use /g %d to teleport here!", gPosInfo[i][gName], i);
- gPosInfo[i][g3DLabel] = CreateDynamic3DTextLabel(string, AREA_MSG, gPosInfo[i][gX], gPosInfo[i][gY], gPosInfo[i][gZ]+0.4, 50);
- gCount++;
- }
- }
- printf("\ngPositional Array Loaded. Number of positions: %i \n\nCurrent gPos Limit: %i\n\n gPosition Slots Left: %i", gCount, MAX_gPOSITIONS, GetgSlotsLeft());
- return 1;
- }
- stock SetPosAndAngle(playerid,Float:x,Float:y,Float:z,Float:ang)
- {
- SetPlayerPos(playerid, x, y, z);
- SetPlayerFacingAngle(playerid,ang);
- SetCameraBehindPlayer(playerid);
- }
Advertisement
Add Comment
Please, Sign In to add comment