PPC_Trucking /endspec respawns player.
#1

Hi guys. I got the PPC_Trucking gamemode with a new problem. When the player types /spec he will spectate fine. But when it comes to /endspec , the command will respawn him, and he will loose his mission, everything. How to make so, that /endspec returns him to his position before /spec , so he can continue mission?
Reply
#2

Can you show us the command code please?
Reply
#3

Yup. Here they are:
Код:
COMMAND:spec(playerid, params[])
{
	// Setup local variables
	new OtherPlayer, Name[24], Msg[128];

	// Send the command to all admins so they can see it
	SendAdminText(playerid, "/spec", params);

	// Check if the player has logged in
	if (APlayerData[playerid][LoggedIn] == true)
	{
		// Check if the player's admin-level is at least 1
		if (APlayerData[playerid][PlayerLevel] >= 1)
		{
			if (sscanf(params, "u", OtherPlayer)) SendClientMessage(playerid, 0xFF0000AA, "Usage: \"/spec <OtherPlayer>\"");
			else
			{
				// Check if that other player is online
				if (IsPlayerConnected(OtherPlayer))
				{
					// Get the player's name
					GetPlayerName(OtherPlayer, Name, sizeof(Name));

				    // Turn spectating on
				    TogglePlayerSpectating(playerid, 1);

					// Check if the other player is driving a vehicle
					if (GetPlayerVehicleSeat(OtherPlayer) == -1)
					{
						// The other player is on foot, so spectate him
						PlayerSpectatePlayer(playerid, OtherPlayer);
						SetPlayerInterior(playerid, GetPlayerInterior(OtherPlayer));
						APlayerData[playerid][SpectateID] = OtherPlayer;
						APlayerData[playerid][SpectateType] = ADMIN_SPEC_TYPE_PLAYER;
					}
					else
					{
						// The other player is in a vehicle, so spectate the vehicle
						PlayerSpectateVehicle(playerid, GetPlayerVehicleID(OtherPlayer));
						APlayerData[playerid][SpectateID] = OtherPlayer;
						APlayerData[playerid][SpectateVehicle] = GetPlayerVehicleID(OtherPlayer);
						APlayerData[playerid][SpectateType] = ADMIN_SPEC_TYPE_VEHICLE;
					}

					format(Msg, 128, "{00FF00}You're spectating {FFFF00}%s", Name);
					SendClientMessage(playerid, 0xFFFFFFFF, Msg);
				}
				else
				    SendClientMessage(playerid, 0xFFFFFFFF, "{FF0000}That player isn't online");
			}
		}
		else
		    return 0;
	}
	else
	    return 0;

	// Let the server know that this was a valid command
	return 1;
}

// This command ends the spectate mode
COMMAND:endspec(playerid, params[])
{
	// Send the command to all admins so they can see it
	SendAdminText(playerid, "/endspec", params);

	// Check if the player has logged in
	if (APlayerData[playerid][LoggedIn] == true)
	{
		// Check if the player's admin-level is at least 1
		if (APlayerData[playerid][PlayerLevel] >= 1)
		{
			// Check if the player is spectating
			if (GetPlayerState(playerid) == PLAYER_STATE_SPECTATING)
			{
			    TogglePlayerSpectating(playerid, 0);
				APlayerData[playerid][SpectateID] = -1;
				APlayerData[playerid][SpectateVehicle] = -1;
				APlayerData[playerid][SpectateType] = ADMIN_SPEC_TYPE_NONE;
			}
			else
			    SendClientMessage(playerid, 0xFFFFFFFF, "{FF0000}You are not spectating");
		}
		else
		    return 0;
	}
	else
	    return 0;

	// Let the server know that this was a valid command
	return 1;
}
Reply
#4

Any idea?
Reply
#5

Bump!
Reply
#6

Well, i'm not going to write the script for you, i will assume you know that. All you need to do is save player's current position when he types /spec (I recommend SetPVarFloat(...) and then when he types /endspec you spawn the player and return him to the GetPVarFloat(... position. I don't think there is an easier way of doing it. The same goes for score, weapons etc. You have to save it in a variable on /spec, and return it back on /endspec.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)