[HELP] Please! Command Spec (Save my arms, money and my position.)?
#1

Please! Help me spec this command, because when I use spec off I lose my arms, money and my position. Anyone know how to fix it, so when I wear spec off I go back to previous position with arms and money they had. Thanks

Код:
dcmd_spec(playerid,params[]) {
	if(IsPlayerCommandLevel(playerid,"spec")) {
	  if(!strlen(params)) return SendClientMessage(playerid,red,"Syntax Error: \"/SPEC <NICK OR ID | OFF>\".");
    new id;
		if(!IsNumeric(params)) {
		  if(!strcmp(params,"off",true)) {
		    if(!Spec[playerid][Spectating]) return SendClientMessage(playerid,red,"ERROR: You must be spectating.");
		    SendCommandMessageToAdmins(playerid,"SPEC OFF");
		    TogglePlayerSpectating(playerid,false);
		    Spec[playerid][Spectating] = false;
		    return SendClientMessage(playerid,yellow,"You have turned your spectator mode off.");
		  }
		 	id = ReturnPlayerID(params);
		}
		else id = strval(params);
		if(IsPlayerConnected(id) && id != INVALID_PLAYER_ID && id != playerid) {
		  SendCommandMessageToAdmins(playerid,"SPEC");
		  new string[256],name[24]; GetPlayerName(id,name,24);
		  if(Spec[id][Spectating]) return SendClientMessage(playerid,red,"Error: You can not spectate a player already spectating.");
	    if(Spec[playerid][Spectating] && Spec[playerid][SpectateID] == id) return SendClientMessage(playerid,red,"ERROR: You are already spectating this player.");
			Spec[playerid][Spectating] = true, Spec[playerid][SpectateID] = id;
	    SetPlayerInterior(playerid,GetPlayerInterior(id));
	    TogglePlayerSpectating(playerid,true);
			if(!IsPlayerInAnyVehicle(id)) PlayerSpectatePlayer(playerid,id);
			else PlayerSpectateVehicle(playerid,GetPlayerVehicleID(id));
	  	format(string,256,"You are now spectating player \"%s\".",name); return SendClientMessage(playerid,yellow,string);
		} else return SendClientMessage(playerid,red,"ERROR: You can not spectate yourself or a disconnected player.");
	} else return SendLevelErrorMessage(playerid,"spec");
}
Reply
#2

Can you show your spec off command?
Reply
#3

The control for off spec is already there!

PS: Can someone help me?
Reply
#4

try to put it up there on top!
Код:
new Float:x[MAX_PLAYERS], Float:y[MAX_PLAYERS], Float:z[MAX_PLAYERS];
Код:
GetPlayerPos(playerid, x[playerid], y[playerid], z[playerid]); //enter the command you put  
SetPlayerPos(playerid, x[playerid], y[playerid], z[playerid]); //In the command to leave
Do not know if going to work more tries there.

Reply
#5

Well, I was told the other day that leaving spectate will reset your player weapons and heal your player.
Also, OnPlayerSpawn will be called.

Check OnPlayerSpawn for money code, it might be resetting it there.

Lose your position? Of course, it will respawn the player.

This would work:
pawn Код:
new BeforeSpectate[MAX_PLAYERS][3];
pawn Код:
//above TogglePlayerSpectating(playerid,true);
GetPlayerPos(playerid, BeforeSpectate[playerid][0],BeforeSpectate[playerid][1],BeforeSpectate[playerid][2]);
pawn Код:
OnPlayerSpawn(playerid)
{
    if(BeforeSpectate[playerid][0]!=0.0)
    {
        GetPlayerPos(playerid, BeforeSpectate[playerid][0],BeforeSpectate[playerid][1],BeforeSpectate[playerid][2]);
        BeforeSpectate[playerid][0]=0.0,BeforeSpectate[playerid][1]=0.0,,BeforeSpectate[playerid][2]=0.0;  
        return 1;
    }
    //rest of code
}
Might want to also get interior and virtual world. Store them like BeforeSpectate and reapply them when the player spawns
Reply
#6

Remove SpawnPlayer(playerid); from the specoff command.
Reply
#7

Rac3r gave the following errors here:
Код:
D:\SA-MP (SERVER)\SA-MP (R7)\filterscripts\Admin.pwn(159) : warning 213: tag mismatch
D:\SA-MP (SERVER)\SA-MP (R7)\filterscripts\Admin.pwn(159) : warning 213: tag mismatch
D:\SA-MP (SERVER)\SA-MP (R7)\filterscripts\Admin.pwn(159) : warning 213: tag mismatch
D:\SA-MP (SERVER)\SA-MP (R7)\filterscripts\Admin.pwn(160) : warning 213: tag mismatch
D:\SA-MP (SERVER)\SA-MP (R7)\filterscripts\Admin.pwn(160) : warning 213: tag mismatch
D:\SA-MP (SERVER)\SA-MP (R7)\filterscripts\Admin.pwn(160) : error 029: invalid expression, assumed zero
D:\SA-MP (SERVER)\SA-MP (R7)\filterscripts\Admin.pwn(160) : warning 213: tag mismatch
D:\SA-MP (SERVER)\SA-MP (R7)\filterscripts\Admin.pwn(163) : warning 217: loose indentation
D:\SA-MP (SERVER)\SA-MP (R7)\filterscripts\Admin.pwn(164) : warning 209: function "OnPlayerSpawn" should return a value
D:\SA-MP (SERVER)\SA-MP (R7)\filterscripts\Admin.pwn(1111) : warning 213: tag mismatch
D:\SA-MP (SERVER)\SA-MP (R7)\filterscripts\Admin.pwn(1111) : warning 213: tag mismatch
D:\SA-MP (SERVER)\SA-MP (R7)\filterscripts\Admin.pwn(1111) : warning 213: tag mismatch
Код:
public OnPlayerSpawn(playerid) {
	if(BeforeSpectate[playerid][0]!=0.0)
	{
		GetPlayerPos(playerid, BeforeSpectate[playerid][0],BeforeSpectate[playerid][1],BeforeSpectate[playerid][2]);
		BeforeSpectate[playerid][0]=0.0,BeforeSpectate[playerid][1]=0.0,,BeforeSpectate[playerid][2]=0.0;
		return 1;
	}
  if(Variables[playerid][Jailed]) { SetPlayerInterior(playerid,3); SetPlayerPos(playerid,197.6661,173.8179,1003.0234); SetPlayerFacingAngle(playerid,0); }
}
Код:
dcmd_spec(playerid,params[]) {
	if(IsPlayerCommandLevel(playerid,"spec")) {
	  if(!strlen(params)) return SendClientMessage(playerid,red,"Syntax Error: \"/SPEC <NICK OR ID | OFF>\".");
    new id;
		if(!IsNumeric(params)) {
		  if(!strcmp(params,"off",true)) {
		    if(!Spec[playerid][Spectating]) return SendClientMessage(playerid,red,"ERROR: You must be spectating.");
             GetPlayerPos(playerid, BeforeSpectate[playerid][0],BeforeSpectate[playerid][1],BeforeSpectate[playerid][2]);
		    SendCommandMessageToAdmins(playerid,"SPEC OFF");
		    TogglePlayerSpectating(playerid,false);
		    Spec[playerid][Spectating] = false;
		    return SendClientMessage(playerid,yellow,"You have turned your spectator mode off.");
		  }
		 	id = ReturnPlayerID(params);
		}
		else id = strval(params);
		if(IsPlayerConnected(id) && id != INVALID_PLAYER_ID && id != playerid) {
		  SendCommandMessageToAdmins(playerid,"SPEC");
		  new string[256],name[24]; GetPlayerName(id,name,24);
		  if(Spec[id][Spectating]) return SendClientMessage(playerid,red,"Error: You can not spectate a player already spectating.");
	    if(Spec[playerid][Spectating] && Spec[playerid][SpectateID] == id) return SendClientMessage(playerid,red,"ERROR: You are already spectating this player.");
			Spec[playerid][Spectating] = true, Spec[playerid][SpectateID] = id;
	    SetPlayerInterior(playerid,GetPlayerInterior(id));
	    TogglePlayerSpectating(playerid,true);
			if(!IsPlayerInAnyVehicle(id)) PlayerSpectatePlayer(playerid,id);
			else PlayerSpectateVehicle(playerid,GetPlayerVehicleID(id));
	  	format(string,256,"You are now spectating player \"%s\".",name); return SendClientMessage(playerid,yellow,string);
		} else return SendClientMessage(playerid,red,"ERROR: You can not spectate yourself or a disconnected player.");
	} else return SendLevelErrorMessage(playerid,"spec");
}







Reply
#8

Help!
Reply


Forum Jump:


Users browsing this thread: