SA-MP Forums Archive
Problem with TogglePlayerSpectating - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Problem with TogglePlayerSpectating (/showthread.php?tid=391980)



Problem with TogglePlayerSpectating - TuTh - 12.11.2012

i have a problem with this comm, when the spectating is over, the server spawn me Instead of giving me where I was

Код:
}
	if (strcmp(cmd, "/findmycar", true) ==0 )
	{
	    if(IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid, COLOR_GREY, "* You can't use this command from inside a vehicle");
	    if(GetPlayerInterior(playerid) != 0) return SendClientMessage(playerid, COLOR_GREY, "You can't use this command from an interior");
		if(dini_Int(PFile(playerid),"HaveCar") == 0) return SendClientMessage(playerid, COLOR_GREY, "   You don't have a personal car !");
	    /*if(transporter[playerid] != 0)
		{
			SendClientMessage(playerid, COLOR_GREY, "On a mission right now, can't use this command !");
		    return 1;
		}*/
		if(PlayerInfo[playerid][pFindcarTime] == 0)
		{
			new Float:A, Float:B, Float:C;
			findcar[playerid] = 1;
			GetVehiclePos(Pc(playerid),A,B,C);
			SetPlayerMapIcon(playerid, 99, A, B, C, 55, 0, MAPICON_GLOBAL_CHECKPOINT);
			PlayerInfo[playerid][pFindcarTime] = 60;
			new Float:ax,Float:ay,Float:az;
			GetPlayerPos(playerid,ax,ay,az);
			findcarX[playerid] = ax;
			findcarY[playerid] = ay;
			findcarZ[playerid] = az;
			TogglePlayerSpectating(playerid, 1);
			PlayerSpectateVehicle(playerid, Pc(playerid));
			SetTimerEx("specfind", 5000, 0, "d", playerid);
			SendClientMessage(playerid, COLOR_LIGHTBLUE, "* Your current car position has been shown as a car icon on the map");
			return 1;
		}
		else
		{
		    format(string, sizeof(string), "Trebuie sa astepti %d secunde pentru a recauta masina !", PlayerInfo[playerid][pFindcarTime]);
        	SendClientMessage(playerid, COLOR_GREY, string);
        	return 1;
		}

public specfind(playerid)
{
	TogglePlayerSpectating(playerid, 0);
	SetPlayerPos(playerid, findcarX[playerid], findcarY[playerid], findcarZ[playerid]);
	return 1;
}
and here why the car is respawning after some minutes ? respawn_delay is not infinite for -1?

Код:
new car = CreateVehicle(VehicleSystem[i][cmodel],VehicleSystem[i][xc],VehicleSystem[i][yc],VehicleSystem[i][zc],VehicleSystem[i][ac],VehicleSystem[i][Farbe1],VehicleSystem[i][Farbe2],-1);



Re: Problem with TogglePlayerSpectating - Abhishek. - 12.11.2012

Код:
new car = CreateVehicle(VehicleSystem[i][cmodel],VehicleSystem[i][xc],VehicleSystem[i][yc],VehicleSystem[i][zc],VehicleSystem[i][ac],VehicleSystem[i][Farbe1],VehicleSystem[i][Farbe2],-1);
to
new car = CreateVehicle(VehicleSystem[i][cmodel],VehicleSystem[i][xc],VehicleSystem[i][yc],VehicleSystem[i][zc],VehicleSystem[i][ac],VehicleSystem[i][Farbe1],VehicleSystem[i][Farbe2],0);
//as if i think.
and dont get and Spawn the player at its pos because you havent alterd the pos anytime in the command you just spectated and came back but you took the player pos while he was spectating so most proably it took the specating point cord


Re: Problem with TogglePlayerSpectating - TuTh - 12.11.2012

Quote:
Originally Posted by [bot]fatninja
Посмотреть сообщение
and dont get and Spawn the player at its pos because you havent alterd the pos anytime in the command you just spectated and came back but you took the player pos while he was spectating so most proably it took the specating point cord
don't work. it spawn me again


Re: Problem with TogglePlayerSpectating - Abhishek. - 12.11.2012

well where exactly it spawns you ?
where the player's veh. was?
and you can give a try to this
pawn Код:
if (strcmp(cmd, "/findmycar", true) ==0 )
    {
            new Float:ax,Float:ay,Float:az;
            GetPlayerPos(playerid,ax,ay,az);
            findcarX[playerid] = ax;
            findcarY[playerid] = ay;
            findcarZ[playerid] = az;
        if(IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid, COLOR_GREY, "* You can't use this command from inside a vehicle");
        if(GetPlayerInterior(playerid) != 0) return SendClientMessage(playerid, COLOR_GREY, "You can't use this command from an interior");
        if(dini_Int(PFile(playerid),"HaveCar") == 0) return SendClientMessage(playerid, COLOR_GREY, "   You don't have a personal car !");
        /*if(transporter[playerid] != 0)
        {
            SendClientMessage(playerid, COLOR_GREY, "On a mission right now, can't use this command !");
            return 1;
        }*/

        if(PlayerInfo[playerid][pFindcarTime] == 0)
        {
            new Float:A, Float:B, Float:C;
            findcar[playerid] = 1;
            GetVehiclePos(Pc(playerid),A,B,C);
            SetPlayerMapIcon(playerid, 99, A, B, C, 55, 0, MAPICON_GLOBAL_CHECKPOINT);
            PlayerInfo[playerid][pFindcarTime] = 60;
            TogglePlayerSpectating(playerid, 1);
            PlayerSpectateVehicle(playerid, Pc(playerid));
            SetTimerEx("specfind", 5000, 0, "d", playerid);
            SendClientMessage(playerid, COLOR_LIGHTBLUE, "* Your current car position has been shown as a car icon on the map");
            return 1;
        }
        else
        {
            format(string, sizeof(string), "Trebuie sa astepti %d secunde pentru a recauta masina !", PlayerInfo[playerid][pFindcarTime]);
            SendClientMessage(playerid, COLOR_GREY, string);
            return 1;
        }



Re: Problem with TogglePlayerSpectating - TuTh - 12.11.2012

don't work.... it spawns me at the faction spawn (public setplayerspawn)