SetPlayerPos doesn't work on OnPlayerExitVehicle
#1

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

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.
Reply
#2

Are you sure "OnPlayerExitVehicle" is called when you 'leave' RC vehicles ? Why don't you use 'OnPlayerStateChange' ? That should work...
Reply
#3

Quote:
Originally Posted by antonio112
Посмотреть сообщение
Are you sure "OnPlayerExitVehicle" is called when you 'leave' RC vehicles ? Why don't you use 'OnPlayerStateChange' ? That should work...
As you can see, here is the original OnPlayerExitVehicle:

pawn Код:
public OnPlayerExitVehicle(playerid, vehicleid)
{
    for(new i=0;i<26;i++)
    {
        if(RCWarCar[i] == vehicleid) Cars[i] = 0;
        if(Kart[i] == vehicleid)
        {
            Karts[i] = 0;
            Player[playerid] = 0;
            SetPlayerInterior(playerid,0);
            SetPlayerPos(playerid,1173.4355,1355.9640,10.9219);
            SetPlayerFacingAngle(playerid,88.9805);
            SendClientMessage(playerid,0x00C7FFAA,"Bye, noob");
        }
    }
    return 1;
}
and all author's actions are working well. The only thing that is not working is my SetPlayerPos.
Reply
#4

Quote:
Originally Posted by WellDone
Посмотреть сообщение
and all author's actions are working well. The only thing that is not working is my SetPlayerPos.
Wich means it's a script problem, and the title is misleading. SetPlayerPos DOES work on OnPlayerExitVehicle.
Reply
#5

pawn Код:
if(RCWarCar[i] == vehicleid)
I don't see you setting this variable anywhere, so you are probably checking against an empty variable. Which will only make the statement true if the vehicleid is 0
Reply
#6

Quote:
Originally Posted by WellDone
Посмотреть сообщение
As you can see, here is the original OnPlayerExitVehicle:

pawn Код:
public OnPlayerExitVehicle(playerid, vehicleid)
{
    for(new i=0;i<26;i++)
    {
        if(RCWarCar[i] == vehicleid) Cars[i] = 0;
        if(Kart[i] == vehicleid)
        {
            Karts[i] = 0;
            Player[playerid] = 0;
            SetPlayerInterior(playerid,0);
            SetPlayerPos(playerid,1173.4355,1355.9640,10.9219);
            SetPlayerFacingAngle(playerid,88.9805);
            SendClientMessage(playerid,0x00C7FFAA,"Bye, noob");
        }
    }
    return 1;
}
and all author's actions are working well. The only thing that is not working is my SetPlayerPos.
dude i think the main prob is onplayerentervehicle cuz u are getting the old position of the player not the new one where the player has driven his vehicle ... so it spawns u where last entered ur vehicle so u need to update your X,Y,Z,Angle every sec that might help
Reply
#7

Quote:
Originally Posted by [FSaF]Jarno
Посмотреть сообщение
Wich means it's a script problem, and the title is misleading. SetPlayerPos DOES work on OnPlayerExitVehicle.
Ermm, I thought anyone could understand that SetPlayerPos doesn't work on OnPlayerExitVehicle in my script, not in general.

Quote:
Originally Posted by FUNExtreme
Посмотреть сообщение
pawn Код:
if(RCWarCar[i] == vehicleid)
I don't see you setting this variable anywhere, so you are probably checking against an empty variable. Which will only make the statement true if the vehicleid is 0
Lol, of course I gave just a part of the script, not the complete code. Of course, the full script has all the needed variables.

As I said, all intended by author is working when player exits vehicle.

Quote:
Originally Posted by -=Dar[K]Lord=-
Посмотреть сообщение
dude i think the main prob is onplayerentervehicle cuz u are getting the old position of the player not the new one where the player has driven his vehicle ... so it spawns u where last entered ur vehicle so u need to update your X,Y,Z,Angle every sec that might help
Ermm, what I want is exactly that player was returned to his position where he has been before he entered a vehicle.
Reply
#8

Quote:
Originally Posted by WellDone
Посмотреть сообщение
Ermm, I thought anyone could understand that SetPlayerPos doesn't work on OnPlayerExitVehicle in my script, not in general.



Lol, of course I gave just a part of the script, not the complete code. Of course, the full script has all the needed variables.

As I said, all intended by author is working when player exits vehicle.



Ermm, what I want is exactly that player was returned to his position where he has been before he entered a vehicle.
ohh srry i didnt understand it properly man ...
Reply
#9

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.


Also I have another problem with this filterscript.
When it's enabled (even the original version), all ambulances become invisible in the mod.
I triple checked, there are no conditions to link ambulances to some interior in the mod, there is only condition to link all vehicles (except RC cars) to the interior 0 by default. But somehow all ambulances on server become invisible with this mini-games filterscript. But, as you can see, there are no such conditions in this script too. Only RC cars.


So I have two problems:

1) can't setplayerpos back when he exits a RCWarCar
2) all ambulances from the mod become invisible with this script. when this script is not enabled, all is okay with them.


Thanks in advance for the help.
Reply
#10

Quote:
Originally Posted by ******
Посмотреть сообщение
Well if you don't provide the full code, how can we see what the problem might be?
Yeah, but when I provide the full code (like now), no one wants to help because of scary amount of code xD
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)