SA-MP Forums Archive
server side car problem? - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: server side car problem? (/showthread.php?tid=423331)



server side car problem? - CBCandyBoy - 17.03.2013

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


Re: server side car problem? - Misiur - 17.03.2013

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


Re: server side car problem? - CBCandyBoy - 17.03.2013

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


Re: server side car problem? - Misiur - 17.03.2013

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;
}



Re: server side car problem? - CBCandyBoy - 17.03.2013

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


Re: server side car problem? - Misiur - 17.03.2013

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;
}



Re: server side car problem? - CBCandyBoy - 18.03.2013

thanks +rep to you


Re: server side car problem? - CBCandyBoy - 18.03.2013

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



Re: server side car problem? - Misiur - 18.03.2013

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


Re: server side car problem? - CBCandyBoy - 18.03.2013

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