Save and Load positions in-game -
DeathKing - 28.05.2013
Introduction
Hello this is my first filterscript for SA-MP + my first post. I made this for the scripters (new once like me) who cant make a position saving system for their server. Please don't be that harsh because this is just my first post and i am still learning SA-MP scripting
Features
-Saving position on foot or vehicle.
-Ability to go back to your saved position.
-Supports vehicle teleport.
-Supports Interior and Virtual Worlds.
-Anti 0,0,0 Spawn or avoiding players doing the load position command without saving any.
-easy to use and nothing else on it because some actually have admin systems with it.
-multiple commands so you could use the command you are used to.....
Download
-
test.pwn = .pwn file (you still have to compile the script)
-
test.amx = .amx file (follow installation right after you download)
-If you don't want to download the files or just want to look at the code look below this message
Код:
#include <a_samp>
#include <zcmd>
new Float:posX[MAX_PLAYERS];
new Float:posY[MAX_PLAYERS];
new Float:posZ[MAX_PLAYERS];
new Float:posA[MAX_PLAYERS];
new Interior[MAX_PLAYERS];
new VirtualWorld[MAX_PLAYERS];
new Saved[MAX_PLAYERS];
public OnFilterScriptInit()
{
print("Save and Load positions filterscript by DeathKing loaded!");
return 1;
}
public OnFilterScriptExit()
{
print("Save and Load positions filterscript by DeathKing unloaded!");
return 1;
}
public OnPlayerConnect(playerid)
{
posX[playerid] = 0.000000, posY[playerid] = 0.000000, posZ[playerid] = 0.000000;
posA[playerid] = 0.000000, Interior[playerid] = 0, VirtualWorld[playerid] = 0;
Saved[playerid] = 0;
return 1;
}
CMD:s(playerid, params[])
{
if(IsPlayerInAnyVehicle(playerid))
{
new vehicleid = GetPlayerVehicleID(playerid);
GetVehiclePos(vehicleid, posX[playerid], posY[playerid], posZ[playerid]);
GetVehicleZAngle(vehicleid, posA[playerid]);
}
else
{
GetPlayerPos(playerid, posX[playerid], posY[playerid], posZ[playerid]);
GetPlayerFacingAngle(playerid, posA[playerid]);
}
Interior[playerid] = GetPlayerInterior(playerid);
VirtualWorld[playerid] = GetPlayerVirtualWorld(playerid);
SendClientMessage(playerid, -1, "You have saved your position");
SendClientMessage(playerid, -1, "Type /r, /loadpos to load your position");
Saved[playerid] = 1;
return 1;
}
CMD:savepos(playerid, params[])
{
return cmd_s(playerid, params);
}
CMD:r(playerid, params[])
{
if(Saved[playerid] == 1)
{
if(IsPlayerInAnyVehicle(playerid))
{
new vehicleid = GetPlayerVehicleID(playerid);
SetVehiclePos(vehicleid, posX[playerid], posY[playerid], posZ[playerid]);
SetVehicleZAngle(vehicleid, posA[playerid]);
LinkVehicleToInterior(vehicleid, Interior[playerid]);
SetVehicleVirtualWorld(vehicleid, VirtualWorld[playerid]);
}
else
{
SetPlayerPos(playerid, posX[playerid], posY[playerid], posZ[playerid]);
SetPlayerFacingAngle(playerid, posA[playerid]);
SetPlayerInterior(playerid, Interior[playerid]);
SetPlayerVirtualWorld(playerid, VirtualWorld[playerid]);
}
SendClientMessage(playerid, -1, "You have loaded your position");
SendClientMessage(playerid, -1, "Type /s, /savepos to save another position");
}
else
{
SendClientMessage(playerid, -1, "ERROR: You cant do that since you have not saved any positions yet");
SendClientMessage(playerid, -1, "Type /s, /savepos to save a position");
}
return 1;
}
CMD:loadpos(playerid, params[])
{
return cmd_r(playerid, params);
}
Installation
-Download the file
-Put it in your server directory in filterscripts folder
-open server.cfg
-on the filterscripts line add the name of what you named the filterscript i made
-save and open your server
Usage
-Just get in the position you want and do /s or /savepos and when you want to go back do /r or /loadpos
Credits
-SAMP dev for SAMP
-Zeex for Zcmd
-me for making the script itself
Notes
-the code that is posted here can have indentation mistakes but on the original script its fixed.....
-if you like my work +rep me i would apriciate it
Re: Save and Load positions in-game -
kjek98 - 05.06.2013
Good job. +REP
Re: Save and Load positions in-game -
SwisherSweet - 05.06.2013
As this is your first tread, first post, i think this is a very good job, i've been here a while and i actually was looking for a thing like this, im kinda lazy to script this these myself,
Good job
Good luck.
Re: Save and Load positions in-game -
DeathKing - 06.06.2013
thanks!!!!
i will make my script posts better once i finish learning sa-mp functions
Re: Save and Load positions in-game -
Firmnsyh - 16.02.2016
Thanks it's so usefull
Re: Save and Load positions in-game -
DyduShxD - 16.02.2016
Good Job.