Why does this script not work?
#1

Hi, i have trouble with a RC script and a 1 Person seat passenger script.
Look:
pawn Код:
new PlayerVehicle[MAX_PLAYERS];
new bool:IsInOneSeater[MAX_PLAYERS];

//In OnPlayer(dis)Connect, and OnplayerSpawn, the bool will be setted to false.

public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
    if(IsVehicleOneSeater(vehicleid))
    {
        if(ispassenger)
        {
            if(IsInOneSeater[playerid] == false)
            {
                TogglePlayerSpectating(playerid, true);
                PlayerSpectateVehicle(playerid, vehicleid);
                IsInOneSeater[playerid] = true;
                PlayerVehicle[playerid] = vehicleid;
            }
        }
    }
    return 1;
}

public OnVehicleDeath(vehicleid, killerid)
{
    if (IsVehicleOneSeater(vehicleid))
    {
        for(new i; i < GetMaxPlayers(); i++)
        {
            if (IsPlayerConnected(i))
            {
                if (IsInOneSeater[i] == true)
                {
                    if (PlayerVehicle[i] == vehicleid)
                    {
                        TogglePlayerSpectating(i, false);
                        new Float:X,Float:Y,Float:Z,Float:A;
                        GetVehiclePos(vehicleid, X, Y, Z);
                        GetVehicleZAngle(vehicleid, A);
                        X += (2 * floatsin(-A, degrees));
                        Y += (2 * floatcos(-A, degrees));
                        SetPlayerPos(i, X, Y, Z);
                        X += (2 * floatsin(-(A-45.0), degrees));
                        Y += (2 * floatcos(-(A-45.0), degrees));
                        SetPlayerPos(i, X, Y, Z);
                        SetPlayerPos(i, X, Y, Z);
                        SetPlayerFacingAngle(i, A+90);
                        SetCameraBehindPlayer(i);
                        IsInOneSeater[i] = false;
                        PlayerVehicle[i] = 0;
                        SetPlayerHealth(i, 0.0);
                    }
                }
            }
        }
    }
    IsInOneSeater[killerid] = false;
    PlayerVehicle[killerid] = 0;
    return 1;
}


public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
    new vehicleid = GetPlayerVehicleID(playerid), Model = GetVehicleModel(vehicleid);
    new Float:x, Float:y, Float:z, Float:a;
    if(newkeys & KEY_SECONDARY_ATTACK)
    {
        vehicleid = PlayerVehicle[playerid];
        if(GetVehicleModel(PlayerVehicle[playerid]) == IsVehicleOneSeater(PlayerVehicle[playerid]))
        {
            if(IsInOneSeater[playerid] == true)
            {
                TogglePlayerSpectating(playerid, false);
                GetVehiclePos(vehicleid, x, y, z);
                GetVehicleZAngle(vehicleid, a);
                x += (2 * floatsin(-a, degrees));
                y += (2 * floatcos(-a, degrees));
                SetPlayerPos(playerid, x, y, z);
                x += (2 * floatsin(-(a-45.0), degrees));
                x += (2 * floatcos(-(a-45.0), degrees));
                SetPlayerPos(playerid, x, y, z);
                SetPlayerFacingAngle(playerid, a);
                SetCameraBehindPlayer(playerid);
                IsInOneSeater[playerid] = false;
                PlayerVehicle[playerid] = 0;
            }
        }
        else if(vehicleid == 0)
        {
            GetPlayerPos(playerid, x, y, z);
            GetVehicleWithinDistance(x, y, z, 20.0, vehicleid);
            if(IsVehicleRcTram(vehicleid))
            {
                PutPlayerInVehicle(playerid, vehicleid, 0);
            }
        }
        else if(GetVehicleModel(vehicleid) != 449 && (IsVehicleRcTram(vehicleid) || GetVehicleModel(vehicleid) == 594))
        {
            GetPlayerPos(playerid, x, y, z);
            SetPlayerPos(playerid, x+0.5, y, z+1.0);
        }
    }
    return 1;
}

stock GetVehicleWithinDistance(Float:x1, Float:y1, Float:z1, Float:dist, &veh)
{
    new Float:x2, Float:y2, Float:z2, Float:d;
    for(new i = 1; i < MAX_VEHICLES; i++)
    {
        if(GetVehicleModel(i) > 0)
        {
            GetVehiclePos(i, x2, y2, z2);
            x2 -= x1; y2 -= y1; z2 -= z1;
            d = x2*x2 + y2*y2 + z2*z2;
            if(d < dist)
            {
                veh = i;
                dist = d;
            }
        }
    }
}



stock IsVehicleRcTram(vehicleid)
{
    switch(GetVehicleModel(vehicleid))
    {
        case 441, 464, 501, 465, 564, 594: return 1;
    }
    return 0;
}



stock IsVehicleOneSeater(vehicleid)
{
    switch(GetVehicleModel(vehicleid))
    {
        case 406, 425, 430, 432, 435, 441, 446, 448, 449, 450, 452, 453, 454, 460, 464, 465, 472,
             473, 476, 481, 484, 485, 486, 493, 501, 509, 510, 512, 513, 519, 520, 530, 531, 532,
             539, 553, 564, 568, 571, 572, 574, 577, 584, 590, 591, 592, 593, 594, 595, 606, 607,
             608, 610, 611: return true;
    }
    return false;
}
With the RC script part: When i am already IN a RC vehicle, i canget out of it. But i CAN'T enter it. Only my character is a changed of his place.

With the One Seat Passenger:
I can get in a vehicle, but i CAN'T get out of it.


How do i solve this problems?
Reply


Messages In This Thread
Why does this script not work? - by Remi-X - 26.06.2009, 14:27
Re: Why does this script not work? - by Remi-X - 26.06.2009, 19:19
Re: Why does this script not work? - by Remi-X - 26.06.2009, 22:39
Re: Why does this script not work? - by Correlli - 26.06.2009, 22:42
Re: Why does this script not work? - by Remi-X - 26.06.2009, 22:47
Re: Why does this script not work? - by Chrham_2 - 27.06.2009, 00:33
Re: Why does this script not work? - by Grim_ - 27.06.2009, 00:35
Re: Why does this script not work? - by Remi-X - 27.06.2009, 09:55
Re: Why does this script not work? - by Remi-X - 28.06.2009, 21:57

Forum Jump:


Users browsing this thread: 2 Guest(s)