new vehicletaken[MAX_VEHICLES],
passanger[MAX_PLAYERS]
;
public OnGameModeInit()
{
for(new i=0;i != MAX_VEHICLES; i++) if(i != INVALID_VEHICLE_ID) {
vehicletaken[i] = 0;
}
return 1;
}
public OnPlayerConnect(playerid)
{
passanger[playerid] = -1;
return 1;
}
public OnPlayerDisconnect(playerid, reason)
{
passanger[playerid] = -1;
return 1;
}
public OnPlayerSpawn(playerid)
{
passanger[playerid] = -1;
return 1;
}
public OnPlayerDeaths(playerid, killerid, reason)
{
passanger[playerid] = -1;
return 1;
}
public OnVehicleSpawn(vehicleid)
{
vehicletaken[vehicleid] = 0;
return 1;
}
public OnVehicleDeath(vehicleid, killerid)
{
vehicletaken[vehicleid] = 0;
return 1;
}
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
new Float:x,Float:y,Float:z,Float:a;
GetPlayerPos(playerid, x,y,z); GetPlayerFacingAngle(playerid, a);
if(!ispassenger) {
if(vehicletaken[vehicleid] == 1) {
SetPlayerPos(playerid, x,y,z); SetPlayerFacingAngle(playerid, a);
GameTextForPlayer(playerid, "~r~No Car Jacking",1000,4);
}else {
vehicletaken[vehicleid] = 1;
passanger[playerid] = ispassenger;
}
}
return 1;
}
public OnPlayerExitVehicle(playerid, vehicleid)
{
if(passanger[playerid] == 0) {
vehicletaken[vehicleid] = 0;
passanger[playerid] = -1;
}
return 1;
}
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
if(!ispassenger) {
new Float:x, Float:y, Float:z;
For(new i = 0; i < MAX_PLAYERS; ++i){
if(GetPlayerState(i) == PLAYER_STATE_DRIVER && i != playerid) {
SetPlayerPos(playerid, x,y,z+0.1);
GameTextForPlayer(playerid, "~r~No Car Jacking",1000,4);
}else {
vehicletaken[vehicleid] = 1;
passanger[playerid] = ispassenger;
}
}
}
return 1;
}
PHP код:
|
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
if(ispassenger == 0)
{
for(new i = 0; i < MAX_PLAYERS; i++)
{
if(IsPlayerConnected(i))
{
if(IsPlayerInVehicle(i, vehicleid))
{
if(i != playerid)
{
if(GetPlayerState(i) == PLAYER_STATE_DRIVER)
{
new Float:Pos[3];
GetPlayerPos(playerid, Pos[0], Pos[1], Pos[2]);
SetPlayerPos(playerid, Pos[0], Pos[1], Pos[2] + 0.3);
GameTextForPlayer(playerid, "~r~No Car Jacking",1000,4);
break;
}
}
}
}
}
}
return 1;
}
Holy crap, that wouldn't work at all...
pawn Код:
|