Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- CYV by Johurt, 2014/11/08
- */
- new SitInV[MAX_PLAYERS] = {0, ...}, SitInS[MAX_PLAYERS] = {-1, ...}, VehSeat[MAX_VEHICLES][9];
- stock j_CreateVehicle(modelid, Float:x, Float:y, Float:z, Float:angle, color1, color2, respawn_delay)
- {
- new vehicleid = CreateVehicle(modelid, Float:x, Float:y, Float:z, Float:angle, color1, color2, respawn_delay);
- for(new c; c < 9; c++) VehSeat[vehicleid][c] = INVALID_PLAYER_ID;
- return vehicleid;
- }
- #define CreateVehicle j_CreateVehicle
- stock j_DestroyVehicle(vehicleid)
- {
- new vSeats = GetVehicleSeats(GetVehicleModel(vehicleid));
- for(new c; c < vSeats; c++)
- {
- if(VehSeat[vehicleid][c] != INVALID_PLAYER_ID)
- {
- if(SitInV[VehSeat[vehicleid][c]] == vehicleid)
- {
- SitInV[VehSeat[vehicleid][c]] = 0;
- SitInS[VehSeat[vehicleid][c]] = -1;
- }
- VehSeat[vehicleid][c] = INVALID_PLAYER_ID;
- }
- }
- return DestroyVehicle(vehicleid);
- }
- #define DestroyVehicle j_DestroyVehicle
- stock j_LinkVehicleToInterior(vehicleid, interiorid)
- {
- LinkVehicleToInterior(vehicleid, interiorid);
- new vSeats = GetVehicleSeats(GetVehicleModel(vehicleid));
- for(new c; c < vSeats; c++)
- {
- if(VehSeat[vehicleid][c] != INVALID_PLAYER_ID) SetPlayerInterior(VehSeat[vehicleid][c], interiorid);
- }
- return 1;
- }
- #define LinkVehicleToInterior j_LinkVehicleToInterior
- stock j_SetVehicleVirtualWorld(vehicleid, worldid)
- {
- SetVehicleVirtualWorld(vehicleid, worldid);
- new vSeats = GetVehicleSeats(GetVehicleModel(vehicleid));
- for(new c; c < vSeats; c++)
- {
- if(VehSeat[vehicleid][c] != INVALID_PLAYER_ID) SetPlayerVirtualWorld(VehSeat[vehicleid][c], worldid);
- }
- return 1;
- }
- #define SetVehicleVirtualWorld j_SetVehicleVirtualWorld
- public OnGameModeInit()
- {
- new c[2];
- for(c[0] = 0; c[0] < MAX_VEHICLES; c[0]++)
- {
- for(c[1] = 0; c[1] < 9; c[1]++) VehSeat[c[0]][c[1]] = INVALID_PLAYER_ID;
- }
- return 1;
- }
- public OnPlayerConnect(playerid)
- {
- SitInV[playerid] = 0;
- SitInS[playerid] = -1;
- return 1;
- }
- public OnPlayerDisconnect(playerid, reason)
- {
- if(SitInV[playerid] != 0)
- {
- VehSeat[SitInV[playerid]][SitInS[playerid]] = INVALID_PLAYER_ID;
- SitInV[playerid] = 0;
- SitInS[playerid] = -1;
- }
- return 1;
- }
- public OnVehicleDeath(vehicleid, killerid)
- {
- new vSeats = GetVehicleSeats(GetVehicleModel(vehicleid));
- for(new c; c < vSeats; c++)
- {
- if(VehSeat[vehicleid][c] != INVALID_PLAYER_ID)
- {
- if(SitInV[VehSeat[vehicleid][c]] == vehicleid)
- {
- SitInV[VehSeat[vehicleid][c]] = 0;
- SitInS[VehSeat[vehicleid][c]] = -1;
- }
- VehSeat[vehicleid][c] = INVALID_PLAYER_ID;
- }
- }
- return 1;
- }
- public OnPlayerStateChange(playerid, newstate, oldstate)
- {
- if(oldstate == PLAYER_STATE_DRIVER || oldstate == PLAYER_STATE_PASSENGER)
- {
- VehSeat[SitInV[playerid]][SitInS[playerid]] = INVALID_PLAYER_ID;
- SitInV[playerid] = 0;
- SitInS[playerid] = -1;
- }
- if(newstate == PLAYER_STATE_DRIVER || newstate == PLAYER_STATE_PASSENGER)
- {
- new vehicleid = GetPlayerVehicleID(playerid), seatid = GetPlayerVehicleSeat(playerid);
- while(seatid == 128) seatid = GetPlayerVehicleSeat(playerid);
- SitInV[playerid] = vehicleid;
- SitInS[playerid] = seatid;
- VehSeat[SitInV[playerid]][SitInS[playerid]] = playerid;
- }
- return 1;
- }
- stock GetVehicleDriver(vehicleid) return VehSeat[vehicleid][0];
- stock IsAnyPlayerInVehicle(vehicleid)
- {
- new vSeats = GetVehicleSeats(GetVehicleModel(vehicleid));
- for(new c; c < vSeats; c++)
- {
- if(VehSeat[vehicleid][c] != INVALID_PLAYER_ID) return 1;
- }
- return 0;
- }
- stock SendMessageToVehicle(vehicleid, color, text[])
- {
- new vSeats = GetVehicleSeats(GetVehicleModel(vehicleid));
- for(new c; c < vSeats; c++)
- {
- if(VehSeat[vehicleid][c] != INVALID_PLAYER_ID) SendClientMessage(VehSeat[vehicleid][c], color, text);
- }
- return 1;
- }
- stock RemovePlayersFromVehicle(vehicleid, nrid = INVALID_PLAYER_ID)
- {
- new vSeats = GetVehicleSeats(GetVehicleModel(vehicleid));
- for(new c; c < vSeats; c++)
- {
- if(VehSeat[vehicleid][c] != INVALID_PLAYER_ID && VehSeat[vehicleid][c] != nrid) RemovePlayerFromVehicle(VehSeat[vehicleid][c]);
- }
- return 1;
- }
- stock GetEmptyPassangerSeat(vehicleid)
- {
- new vSeats = GetVehicleSeats(GetVehicleModel(vehicleid));
- if(vSeats > 1)
- {
- for(new c = 1; c < vSeats; c++)
- {
- if(VehSeat[vehicleid][c] == INVALID_PLAYER_ID) return c;
- }
- }
- return -1;
- }
- stock GetVehicleSeats(modelid)
- {
- switch(modelid)
- {
- /* 1 */
- case 406, 425, 430, 432, 435, 441, 446, 448, 450, 452..454, 464, 465, 472,
- 473, 476, 481, 484..486, 493, 501, 509, 510, 512, 513, 519, 520, 530..532,
- 539, 553, 564, 568..571, 572, 577, 574, 583, 584, 591, 594, 590, 595,
- 606..608, 610, 611: return 1;
- /* 2 */
- case 401..403, 407, 408, 410..412, 414, 415, 417, 419, 422..424, 429, 433,
- 434, 436, 439, 442..444, 447, 451, 455..457, 460..463, 468, 469, 471, 474,
- 475, 477, 478, 480, 488, 489, 491, 494..496, 499, 500, 502..505, 506, 508,
- 511, 514, 515, 517, 518, 521, 522, 523..526, 528, 527, 533..536, 541..545,
- 548, 549, 552, 554, 555..558, 559, 562, 563, 565, 573, 575, 576, 578, 580,
- 581, 586, 588, 589, 592, 593, 599..603, 605: return 2;
- /* 3 */
- case 483: return 3;
- /* 4 */
- case 400, 404, 405, 409, 413, 416, 418, 420, 421, 426..428, 438, 440, 445,
- 458, 459, 466, 467, 470, 479, 482, 487, 490, 492, 497, 498, 507, 516, 529,
- 540, 546, 547, 550, 551, 560, 561, 566, 567, 579, 582, 585, 587, 596..598,
- 604, 609: return 4;
- /* 9 */
- case 431, 437, 449, 537, 538: return 9;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement