2020-12-30, 10:44 PM
(This post was last modified: 2020-12-30, 10:45 PM by Necmi07.)
How can i do this?
I want people when press g and go interior. (Securicar,Enforcer)
I know it, it's possible but i don't know how can i do this.
Thanks.
2020-12-31, 04:46 PM
(This post was last modified: 2020-12-31, 04:49 PM by xbruno1000x.)
First:
Code: new IsInSecuricar[MAX_PLAYERS];
To enter interior:
Code: public OnPlayerStateChange(playerid, newstate, oldstate)
{
if(newstate == PLAYER_STATE_PASSENGER)
{
if (GetVehicleModel(vehicleid) == SECURICAR ID)
{
SetPlayerPos(playerid, INTERIOR POS);
SetPlayerFacingAngle(playerid, ANGLE);
SetCameraBehindPlayer(playerid);
SetPlayerInterior(playerid, INTERIORID);
IsInSecuricar[playerid] = vehicleid;
}
}
To Exit car interior:
Code: public OnPlayerKeyStateChange(playerid,newkeys,oldkeys)
{
if (newkeys == 16 && IsInSecuricar[playerid] > 0)
{
new Float:X,Float:Y,Float:Z;
GetVehiclePos(IsInSecuricar[playerid], X, Y, Z);
SetPlayerPos(playerid, X, Y, Z);
SetPlayerInterior(playerid, 0);
IsInSecuricar[playerid] = 0;
}
(2020-12-31, 04:46 PM)xbruno1000x Wrote: First:
Code: new IsInSecuricar[MAX_PLAYERS];
To enter interior:
Code: public OnPlayerStateChange(playerid, newstate, oldstate)
{
if(newstate == PLAYER_STATE_PASSENGER)
{
if (GetVehicleModel(vehicleid) == SECURICAR ID)
{
SetPlayerPos(playerid, INTERIOR POS);
SetPlayerFacingAngle(playerid, ANGLE);
SetCameraBehindPlayer(playerid);
SetPlayerInterior(playerid, INTERIORID);
IsInSecuricar[playerid] = vehicleid;
}
}
To Exit car interior:
Code: public OnPlayerKeyStateChange(playerid,newkeys,oldkeys)
{
if (newkeys == 16 && IsInSecuricar[playerid] > 0)
{
new Float:X,Float:Y,Float:Z;
GetVehiclePos(IsInSecuricar[playerid], X, Y, Z);
SetPlayerPos(playerid, X, Y, Z);
SetPlayerInterior(playerid, 0);
IsInSecuricar[playerid] = 0;
}
I couldn?t do it but thank you so much :)
(2021-01-06, 11:28 PM)Necmi07 Wrote: I couldn?t do it but thank you so much :)
What is the issue, more precisely? Perhaps we can help you out.
First and foremost, you will need to find a map that you wish to use as a vehicle interior or create your own map, then make sure that it's implemented in your gamemode.
Afterwards, xbruno1000x's code is pretty straightforward. You only need to add some data to his code referring to entering the interior:
Code: GetVehicleModel(vehicleid) == SECURICAR ID
//in your case, it should be the following for both Securicar and Enforcer:
GetVehicleModel(vehicleid) == 426 || GetVehicleModel(vehicleid) == 427
//while immediately after the accolade you should have:
SetPlayerPos(playerid, 1, 2, 3); //replace 1 with your X coordinate, 2 with your Y coordinate, and 3 with your Z coordinate of the map
SetPlayerFacingAngle(playerid, 0); //replace 0 with your ideal facing angle when spawning inside the interior, so that you will be facing the right way
SetCameraBehindPlayer(playerid);
SetPlayerInterior(playerid, 0); //change it to your map's interior ID, if need be
|