PDA

View Full Version : Un-Jail'ed player pos


noPANDA
10/04/2017, 08:16 AM
my goal is to make it so when a player is released from admin jail (either by an admin or by his time running out) it spawns him back in the place he originally was when he was admin jailed
ive been messing around with GetPlayerPos and SetPlayerPos but im not having any luck
id also like to GetPlayerVirtualWorld and GetPlayerInterior but i could probably figure myself by applying the same method as the GetPlayerPos one

CMD:ajail(playerid, params[])
{
if(pInfo[playerid][pAdminLevel] > 0)
{
new targetid, minutes, reason[205], str[205];
if(sscanf(params, "ris[205]", targetid, minutes, reason)) return SendClientMessage(playerid, COLOR_ADMIN, "USAGE: /ajail [id] [minutes] [reason]");
if(minutes <= 0 || minutes > 180) return SendClientMessage(playerid, COLOR_ADMIN, "ERROR: Minutes can't be less than 0 or more than 180!");
if(inJail[targetid]) return SendClientMessage(playerid, COLOR_ADMIN, "ERROR: This player is already jailed.");
if(targetid == playerid) return SendClientMessage(playerid, COLOR_RED, "You can't jail yourself!");
if(pInfo[targetid][pAdminLevel] > pInfo[playerid][pAdminLevel]) return SendClientMessage(playerid, COLOR_RED, "You can't jail higher level admins!");

format(str, sizeof(str), "%s has jailed %s for %d minute(s), reason: %s", PlayerName(playerid), PlayerName(targetid), minutes, reason);
SendSplitMessageToAll(COLOR_ADMIN, str);
JailTimer[targetid] = SetTimer("Unjail", minutes*60*1000, false);
SetPlayerPos(targetid, 264.4176, 77.8930, 1001.0391);
SetPlayerInterior(playerid, 6);
SetPlayerVirtualWorld(playerid, 99);
inJail[targetid] = true;
}
else return SendClientMessage(playerid, -1, "uhh ur not an admin so why are you trying to do that");
return 1;
}
/************************************************** ************************************************** **********************************************/
CMD:unjail(playerid, params[])
{
if(pInfo[playerid][pAdminLevel] > 0)
{
new targetid, string[128];
if(sscanf(params, "u", targetid)) return SendClientMessage(playerid, COLOR_ADMIN, "/unjail [ID]");
if(!IsPlayerConnected(targetid)) return SendClientMessage(playerid, COLOR_ADMIN, "ERROR: This player is not online.");
if(!inJail[playerid]) return SendClientMessage(playerid, COLOR_ADMIN, "ERROR: This player is not admin jailed.");
if(inJail[targetid])
{
format(string, sizeof(string), "%s has been released from admin jail by %s.", PlayerName(targetid), PlayerName(playerid));
SendSplitMessageToAll(COLOR_ADMIN, string);
SpawnPlayer(playerid);
SetPlayerInterior(playerid, 0);
inJail[playerid] = false;
KillTimer(JailTimer[playerid]);
SendClientMessage(playerid, COLOR_ADMIN, "SERVER: You've been released from admin jail.");
}
}
else return SendClientMessage(playerid, -1, "ey mang ur not an admin so cut it out");
return 1;
}
/************************************************** ************************************************** **********************************************/
forward Unjail(playerid);
public Unjail(playerid)
{
SpawnPlayer(playerid);
SetPlayerInterior(playerid, 0);
inJail[playerid] = false;
KillTimer(JailTimer[playerid]);
SendClientMessage(playerid, COLOR_ADMIN, "SERVER: You've been released from admin jail.");
}

DTV
10/04/2017, 09:10 AM
I don't have the time to test it, but this should work.


//global vars
new Float:AdminJailPos[MAX_PLAYERS][3],AdminJailInterior[MAX_PLAYERS],AdminJailVW[MAX_PLAYERS]; //these are only needed if you didn't plan on saving these variables

CMD:ajail(playerid, params[])
{
if(pInfo[playerid][pAdminLevel] > 0)
{
new targetid, minutes, reason[205], str[205],Float:pPos[3];
if(sscanf(params, "ris[205]", targetid, minutes, reason)) return SendClientMessage(playerid, COLOR_ADMIN, "USAGE: /ajail [id] [minutes] [reason]");
if(minutes <= 0 || minutes > 180) return SendClientMessage(playerid, COLOR_ADMIN, "ERROR: Minutes can't be less than 0 or more than 180!");
if(inJail[targetid]) return SendClientMessage(playerid, COLOR_ADMIN, "ERROR: This player is already jailed.");
if(targetid == playerid) return SendClientMessage(playerid, COLOR_RED, "You can't jail yourself!");
if(pInfo[targetid][pAdminLevel] > pInfo[playerid][pAdminLevel]) return SendClientMessage(playerid, COLOR_RED, "You can't jail higher level admins!");
GetPlayerPos(targetid,pPos[0],pPos[1],pPos[2]);
AdminJailPos[targetid][0] = pPos[0];
AdminJailPos[targetid][1] = pPos[1];
AdminJailPos[targetid][2] = pPos[2];
AdminJailInterior[targetid] = GetPlayerInterior(targetid);
AdminJailVW[targetid] = GetPlayerVirtualWorld(targetid);
format(str, sizeof(str), "%s has jailed %s for %d minute(s), reason: %s", PlayerName(playerid), PlayerName(targetid), minutes, reason);
SendSplitMessageToAll(COLOR_ADMIN, str);
JailTimer[targetid] = SetTimer("Unjail", minutes*60*1000, false);
SetPlayerPos(targetid, 264.4176, 77.8930, 1001.0391);
SetPlayerInterior(playerid, 6);
SetPlayerVirtualWorld(playerid, 99);
inJail[targetid] = true;
}
else return SendClientMessage(playerid, -1, "uhh ur not an admin so why are you trying to do that");
return 1;
}

forward Unjail(playerid);
public Unjail(playerid)
{
SpawnPlayer(playerid);
SetPlayerPos(playerid,AdminJailPos[playerid][0],AdminJailPos[playerid][1],AdminJailPos[playerid][2]);
SetPlayerInterior(playerid, AdminJailInterior[playerid]);
SetPlayerVirtualWorld(playerid,AdminJailVW[playerid]);
inJail[playerid] = false;
KillTimer(JailTimer[playerid]);
AdminJailPos[playerid][0] = 0.0;
AdminJailPos[playerid][1] = 0.0;
AdminJailPos[playerid][2] = 0.0;
AdminJailInterior[playerid] = 0;
AdminJailVW[playerid] = 0;
SendClientMessage(playerid, COLOR_ADMIN, "SERVER: You've been released from admin jail.");
}

Kane
10/04/2017, 09:39 AM
You could set it when you admin jail a player that it does:


GetPlayerPos(playerid, x, y, z);

Player[playerid][LastWorld] = GetPlayerVirtualWorld(playerid);
Player[playerid][LastInterior] = GetPlayerInterior(playerid);
Player[playerid][LastX] = x;
Player[playerid][LastY] = y;
Player[playerid][LastZ] = z;


And then on release, do:


SetPlayerPos(playerid, Player[playerid][LastX], Player[playerid][LastY], Player[playerid][LastZ]);
SetPlayerInterior(playerid, Player[playerid][LastInterior]);
SetPlayerVirtualWorld(playerid, Player[playerid][LastWorld]);

noPANDA
10/04/2017, 12:22 PM
young arthur kane method
will give it a try my best friend
edit: gave me a bunch of errors, probably because of something on my end
young DTV method
didnt work either :{

Kane
11/04/2017, 03:23 AM
will give it a try my best friend
edit: gave me a bunch of errors, probably because of something on my end

didnt work either :{


Because you need to use what you're using to save your positions. That was just an example that I have.


enum PlayerStatistics {

LastX,
Last Y,
LastZ,
LastWorld,
LastInterior
};

as an example.