23.01.2013, 12:16
(
Последний раз редактировалось WellDone; 23.01.2013 в 19:58.
)
Hi all.
I'm currently editing filterscript that is using RC toys. But currently, when player "exits" RC toy, he appears near it, though I want player to appear at that place where he entered the vehicle.
The actual filterscript (credits for the original version belong to GhostTT) with my changes
The only difference between the original filterscript and my edition is an attempt to SetPlayerPos back to where he has been when entered the vehicle after exiting it. Also I added some PVars, but they are for other purposes.
I just can't unserstand why SetPlayerPos doesn't work when player exits RCWarCar.
Author's actions are performing well when player exits them though.
Many thanks in advance for your help.
I'm currently editing filterscript that is using RC toys. But currently, when player "exits" RC toy, he appears near it, though I want player to appear at that place where he entered the vehicle.
The actual filterscript (credits for the original version belong to GhostTT) with my changes
pawn Код:
#include <a_samp>
#include <streamer>
forward NPC();
forward NPCStart();
new Player[MAX_PLAYERS],CompPickup[4];
new RCWarCar[17],Race[5],Kart[6],game[MAX_PLAYERS];
new Cars[16],RCTank[3],RCSamol[5],RCVert[3],Karts[6];
new Float:posX[MAX_PLAYERS];
new Float:posY[MAX_PLAYERS];
new Float:posZ[MAX_PLAYERS];
new Float:posA[MAX_PLAYERS];
public Streamer_OnFilterScriptInit()
{
// There were objects, they are not needed for the explanation
CompPickup[1] = CreateDynamicPickup(1277,1,1174.3053,1360.9205,10.9219,-1);
CompPickup[2] = CreateDynamicPickup(1277,1,1166.0970,1353.1891,10.9219,-1);
CompPickup[3] = CreateDynamicPickup(1277,1,1174.1499,1348.5989,10.9219,-1);
// Cars
Kart[1] = AddStaticVehicle(571,1117.0093,2255.3591,19.0465,89.6824,36,2); //
Kart[2] = AddStaticVehicle(571,1113.5677,2255.3201,19.0468,92.4526,51,53); //
Kart[3] = AddStaticVehicle(571,1109.7043,2255.3005,19.0467,90.2476,91,2); //
Kart[4] = AddStaticVehicle(571,1106.5037,2255.2097,19.0467,89.4839,11,22); //
Kart[5] = AddStaticVehicle(571,1102.5692,2255.2590,19.0467,92.1046,40,35); //
Race[1] = AddStaticVehicle(571,1117.0093,2255.3591,19.0465,89.6824,36,2); //
Race[2] = AddStaticVehicle(571,1113.5677,2255.3201,19.0468,92.4526,51,53); //
Race[3] = AddStaticVehicle(571,1109.7043,2255.3005,19.0467,90.2476,91,2); //
Race[4] = AddStaticVehicle(571,1106.5037,2255.2097,19.0467,89.4839,11,22); //
RCWarCar[1] = AddStaticVehicle(564,-1136.3162,1019.0483,1345.0835,270.5313,0,0); // Tiger (watch rcwar)
RCWarCar[2] = AddStaticVehicle(464,-1130.5699,1027.8213,1345.0131,272.9121,14,75); // Baron
RCWarCar[3] = AddStaticVehicle(464,-1130.4882,1030.2493,1345.0162,269.2135,14,75); // Baron
RCWarCar[4] = AddStaticVehicle(464,-1128.1396,1027.9340,1345.0026,270.3515,14,75); // Baron
RCWarCar[5] = AddStaticVehicle(464,-1128.1316,1030.2913,1345.0017,269.7841,14,75); // Baron
RCWarCar[6] = AddStaticVehicle(564,-1117.7897,1019.2189,1345.0835,270.5296,0,0); // Tiger (watch rcwar)
RCWarCar[7] = AddStaticVehicle(564,-1130.9722,1019.0976,1345.0835,270.5307,0,0); // Tiger (watch rcwar)
RCWarCar[8] = AddStaticVehicle(501,-1130.0284,1040.6913,1345.2063,271.9564,14,75); // Goblin
RCWarCar[9] = AddStaticVehicle(501,-1129.9369,1042.6572,1345.2371,274.4154,14,75); // Goblin
RCWarCar[10] = AddStaticVehicle(564,-1132.1053,1057.8380,1345.5826,269.6947,0,0); // Tiger
RCWarCar[11] = AddStaticVehicle(564,-1129.5297,1057.8292,1345.5835,269.8691,0,0); // Tiger
RCWarCar[12] = AddStaticVehicle(441,-1134.7843,1038.3818,1344.8730,226.6530,79,42); // Bandit
RCWarCar[13] = AddStaticVehicle(441,-1128.2644,1038.5522,1344.8311,224.6958,79,42); // Bandit
RCWarCar[14] = AddStaticVehicle(594,-1125.7714,1053.2950,1344.8958,165.9683,0,0); // RC Cam
RCWarCar[15] = AddStaticVehicle(594,-1125.9305,1052.1727,1344.8954,169.6070,0,0); // RC Cam
RCWarCar[16] = AddStaticVehicle(594,-1131.6476,1054.9731,1344.9418,198.3954,0,0); // RC Cam
RCTank[1] = AddStaticVehicle(564,-1126.4869,1019.1389,1358.0835,270.5305,0,0); // Tiger (watch rcwar)
RCTank[2] = AddStaticVehicle(564,-1122.3527,1019.1770,1358.0835,270.5303,0,0); // Tiger (watch rcwar)
RCVert[1] = AddStaticVehicle(501,-1133.0339,1040.7697,1345.2501,272.7063,14,75); // Goblin
RCVert[2] = AddStaticVehicle(501,-1133.1169,1042.7013,1345.2675,273.8671,14,75); // Goblin
RCSamol[1] = AddStaticVehicle(464,-1125.8718,1027.9491,1344.9882,267.8098,14,75); // Baron
RCSamol[2] = AddStaticVehicle(464,-1125.8781,1030.2914,1344.9885,270.9232,14,75); // Baron
RCSamol[3] = AddStaticVehicle(464,-1133.0215,1030.2168,1345.0315,271.6719,14,75); // Baron
RCSamol[4] = AddStaticVehicle(464,-1133.2302,1027.8629,1345.0304,270.6061,14,75); // Baron
NPCStart();
for(new i=1;i<17;i++)
{
SetPVarInt(RCWarCar[i],"noinvis",1);
Cars[i] = 0;
LinkVehicleToInterior(RCWarCar[i],10);
if(i < 3)
{
SetPVarInt(RCVert[i],"noinvis",1);
SetPVarInt(RCTank[i],"noinvis",1);
LinkVehicleToInterior(RCVert[i],10);
LinkVehicleToInterior(RCTank[i],10);
}
if(i < 5)
{
SetPVarInt(RCSamol[i],"noinvis",1);
LinkVehicleToInterior(RCSamol[i],10);
SetPVarInt(Race[i],"noinvis",1);
}
if(i<6) SetPVarInt(Kart[i],"noinvis",1);
}
return 1;
}
public Streamer_OnPlayerConnect(playerid)
{
if(IsPlayerNPC(playerid))
{
SetPVarInt(playerid,"bot",1);
return 1;
}
else return 1;
}
public Streamer_OnPlayerDisconnect(playerid, reason)
{
if(IsPlayerNPC(playerid)) return 1;
Player[playerid] = 0;
if(game[playerid] == 1) Cars[Player[playerid]] = 0;
else if(game[playerid] == 2) Karts[Player[playerid]] = 0;
return 1;
}
public OnPlayerRequestClass(playerid, classid)
{
if(IsPlayerNPC(playerid)) SetSpawnInfo(playerid,1,110,0.0,0.0,0.0,0.0,0,0,0,0,0,0);
}
public OnPlayerSpawn(playerid)
{
new npcname[40];
GetPlayerName(playerid,npcname,sizeof(npcname));
if(!strcmp(npcname,"Vertolet",true)) PutPlayerInVehicle(playerid,RCVert[1],1);
if(!strcmp(npcname,"Vertolet2",true)) PutPlayerInVehicle(playerid,RCVert[2],1);
if(!strcmp(npcname,"Samolet",true)) PutPlayerInVehicle(playerid,RCSamol[1],1);
if(!strcmp(npcname,"Samolet2",true)) PutPlayerInVehicle(playerid,RCSamol[2],1);
if(!strcmp(npcname,"Samolet3",true)) PutPlayerInVehicle(playerid,RCSamol[3],1);
if(!strcmp(npcname,"Samolet4",true)) PutPlayerInVehicle(playerid,RCSamol[4],1);
if(!strcmp(npcname,"Tank",true)) PutPlayerInVehicle(playerid,RCTank[1],1);
if(!strcmp(npcname,"Tank2",true)) PutPlayerInVehicle(playerid,RCTank[2],1);
if(!strcmp(npcname,"Racer",true)) PutPlayerInVehicle(playerid,Race[1],1);
if(!strcmp(npcname,"Racer2",true)) PutPlayerInVehicle(playerid,Race[2],1);
if(!strcmp(npcname,"Racer3",true)) PutPlayerInVehicle(playerid,Race[3],1);
if(!strcmp(npcname,"Racer4",true)) PutPlayerInVehicle(playerid,Race[4],1);
return 1;
}
public OnPlayerDeath(playerid, killerid, reason)
{
if(IsPlayerNPC(playerid)) return 1;
if(game[playerid] == 1) Cars[Player[playerid]] = 0;
else if(game[playerid] == 2) Karts[Player[playerid]] = 0;
game[playerid] = 0;
SetPVarInt(playerid,"nofuel",0);
return 1;
}
public NPCStart()
{
ConnectNPC("Samolet","samol_rc");
ConnectNPC("Samolet3","samol_rc2");
ConnectNPC("Vertoler","vert_rc");
ConnectNPC("Tank","tank_rc");
ConnectNPC("Racer","nfs");
ConnectNPC("Racer2","nfs2");
SetTimer("NPC",10000,0);
}
public OnPlayerCommandText(playerid, cmdtext[])
{
if(strcmp(cmdtext,"/stopgame",true) == 0)
{
if(Player[playerid] != 0)
{
SetPVarInt(playerid,"nofuel",0);
if(game[playerid] == 1) Cars[Player[playerid]] = 0;
else if(game[playerid] == 2) Karts[Player[playerid]] = 0;
Player[playerid] = 0;
RemovePlayerFromVehicle(playerid);
SetPlayerInterior(playerid,0);
SetPlayerPos(playerid,1173.4355,1355.9640,10.9219);
SetPlayerFacingAngle(playerid,88.9805);
SendClientMessage(playerid,0x00C7FFAA,"Exit succesful");
}
else SendClientMessage(playerid,0xCC0000AA,"Exit not succesful");
return 1;
}
return 0;
}
public NPC()
{
ConnectNPC("Samolet2","samol_rc");
ConnectNPC("Vertoler2","vert_rc");
ConnectNPC("Tank2","tank_rc");
ConnectNPC("Samolet4","samol_rc2");
ConnectNPC("Racer3","nfs");
ConnectNPC("Racer4","nfs2");
}
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
if(!IsPlayerNPC(playerid))
{
GetPlayerPos(playerid,posX[playerid],posY[playerid],posZ[playerid]);
GetPlayerFacingAngle(playerid,posA[playerid]);
}
else return 1;
return 1;
}
public OnPlayerExitVehicle(playerid, vehicleid)
{
for(new i=0;i<26;i++)
{
if(RCWarCar[i] == vehicleid)
{
SetPlayerPos(playerid,posX[playerid],posY[playerid],posZ[playerid]);
SetPlayerFacingAngle(playerid,posA[playerid]);
Cars[i] = 0;
}
else if(Kart[i] == vehicleid)
{
SetPVarInt(playerid,"nofuel",0);
Karts[i] = 0;
Player[playerid] = 0;
SetPlayerInterior(playerid,0);
SetPlayerPos(playerid,1173.4355,1355.9640,10.9219);
SetPlayerFacingAngle(playerid,88.9805);
SendClientMessage(playerid,0xFF0000FF,"Bye, noob");
}
}
return 1;
}
public OnPlayerPickUpDynamicPickup(playerid, pickupid)
{
if(pickupid == CompPickup[1] || pickupid == CompPickup[2] || pickupid == CompPickup[3])
{
ShowPlayerDialog(playerid,100,DIALOG_STYLE_LIST,"Choose game:","Mini GTA\nMini NFS\n","ОК","Отмена");
}
return 1;
}
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
if(dialogid == 100)
{
if(response)
{
GivePlayerMoney(playerid,-1000);
if(listitem == 0)
{
SetPVarInt(playerid,"nofuel",1);
SetPlayerInterior(playerid,10);
SetPlayerPos(playerid,-1130.8673,1034.7043,1345.7231);
SetPlayerFacingAngle(playerid,243.5756);
PlayerPlaySound(playerid, 1085, 0.0, 0.0, 0.0);
for(new i=1;i<17;i++)
{
if(Cars[i] == 0)
{
PutPlayerInVehicle(playerid,RCWarCar[i],0);
Cars[i] = 1;
Player[playerid] = i;
SendClientMessage(playerid,0xB8860BAA,"You entered Mini Grand Theft Auto. Good luck!");
SendClientMessage(playerid,0xFF0066AA,"To exit, enter: /stopgame");
game[playerid] = 1;
return 1;
}
if(i == 16)
{
SendClientMessage(playerid,0xCC0000AA,"No empty slots");
return 1;
}
}
}
if(listitem == 1)
{
SetPVarInt(playerid,"nofuel",1);
SetPlayerInterior(playerid,0);
SetPlayerPos(playerid,1117.0093,2255.3591,19.0465);
PlayerPlaySound(playerid, 1085, 0.0, 0.0, 0.0);
for(new i=1;i<6;i++)
{
if(Karts[i] == 0)
{
PutPlayerInVehicle(playerid,Kart[i],0);
Karts[i] = 1;
Player[playerid] = i;
SendClientMessage(playerid,0x33AAFFAA,"You entered Mini Need For Speed. Good luck!");
SendClientMessage(playerid,0xDC143CAA,"To exit, enter: /stopgame");
game[playerid] = 1;
return 1;
}
if(i == 5)
{
SendClientMessage(playerid,0xFF6347AA,"No empty slots");
return 1;
}
}
}
}
}
return 1;
}
The only difference between the original filterscript and my edition is an attempt to SetPlayerPos back to where he has been when entered the vehicle after exiting it. Also I added some PVars, but they are for other purposes.
I just can't unserstand why SetPlayerPos doesn't work when player exits RCWarCar.
Author's actions are performing well when player exits them though.
Many thanks in advance for your help.