server side car problem?
#1

hello everyone i started a new thread after a long time ......

to the point....
idk that i have ever seen this but i want a thing like i have all buyable cars and i want that some cars are unbuyable it says whenever a person enters this is a server side vehicle and is not for sale


i want that if someone enters that vehicle that vehicle is gone and after 2sec's another car of same model but diff color appears at that location and player is still in that previous vehicle
Reply
#2

Using https://sampwiki.blast.hk/wiki/OnPlayerEnterVehicle or https://sampwiki.blast.hk/wiki/OnPlayerStateChange with state player_driver you will detect attempt of entering the vehicle.

https://sampwiki.blast.hk/wiki/SetTimer - with this you can set timeout to 2 seconds. Start trying to write something yourself, we'll be glad to help, but only if you show some effort
Reply
#3

i have many cars but im using satdm some are buyable im adding new cars

https://sampwiki.blast.hk/wiki/OnPlayerStateChange
but it will tell me any player enterring any vehicle i want specific vehicles
Reply
#4

There isn't thing as OnVehicleBeingEnteredByPlayer.

pawn Код:
public OnPlayerStateChange(playerid, newstate, oldstate) {
    if(newstate & PLAYER_STATE_DRIVER) {
        new msg[64];
        format(msg, sizeof msg, "You (%d) are in car %d", playerid, GetPlayerVehicleID(playerid));
        SendClientMessage(playerid, -1, msg);
    }
    return 1;
}
Reply
#5

ok that's ok but i want that if he enters specific vehicle like

CreateVehicle(541, 300.2742, 1863.9669, 17.2396, 0.0000, -1, -1, 100);

and only if he enters that vehicle another vehicle respawns at that place
Reply
#6

pawn Код:
#define MAX_CUSTOM_VEHICLES 5
new CustomVehicles[MAX_CUSTOM_VEHICLES];

//(...)
CustomVehicles[0] = CreateVehicle(541, 300.2742, 1863.9669, 17.2396, 0.0000, -1, -1, 100);

//(...)
public OnPlayerStateChange(playerid, newstate, oldstate) {
    if(newstate & PLAYER_STATE_DRIVER) {
        new vid = GetPlayerVehicleID(playerid), Float:p[4];
        for(new i = 0; i != MAX_CUSTOM_VEHICLES; ++i) { //Alternatively use iterator
        if(CustomVehicles[i] == vid) {
            GetVehiclePos(vid, p[0], p[1], p[2]);
            GetVehicleZAngle(vid, p[3]);
            new model = GetVehicleModel(vid);
            SetTimerEx("RebuildCar", 2000, 0, "iiiffff", playerid, i, model, p[0], p[1], p[2], p[3]);
        }
    }
    }
    return 1;
}

forward RebuildCar(pid, vehi, model, Float:x, Float:y, Float:z, Float:r);
public RebuildCar(pid, vehi, model, Float:x, Float:y, Float:z, Float:r) {
    CustomVehicles[vehi] = CreateVehicle(model, x, y, z, r, -1, -1, 0);
    return 1;
}
Reply
#7

thanks +rep to you
Reply
#8

The car is working but whenever i sit in that it says this taxi is for sale and names of all other cars are disturbed
like this look
Reply
#9

Probably you are creating this vehicles earlier in game than those already scripted, and the vehicleid-to-meta relations are screwed up somehow.
Reply
#10

yes that's right im SATDM and it has cars already and that car is messing up my script in server each car is having its different name how can i fix that in SATDM gamemode
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)