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

Nobody?
Reply
#3

Goddamnit...
Reply
#4

Don't expect help if you're spamming your own topic.
Reply
#5

Yeah, but if the pages reaches the next paga, not many people read them. So i must bump, sorry xD
Reply
#6

turn
Код:
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;
}
to

Код:
stock IsVehicleRcTram(vehicleid) 
{
441, 464, 501, 465, 564, 594
}



stock IsVehicleOneSeater(vehicleid)
{
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
}
Reply
#7

Using Chrham_2's way you could just make an array.

@Chrham_2: Your way won't work either, you just changed it to have an unused "vehicleid" param.
Reply
#8

I still don't know what to do
Reply
#9

Quote:
Originally Posted by Remi-X
I still don't know what to do
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)