public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
if(GetVehicleModel(vehicleid) == your id)
{
SetTimerEx("Message", 5000, false, "i", playerid);
}
return 1;
}
forward Message(playerid);
public Message(playerid)
{
SendClientMessage(playerid, -1, "Welcome to the vehicle.");
SetTimerEx("Explosion", 5000, false, "i", playerid);
return 1;
}
forward Explosion(playerid);
public Explosion(playerid)
{
new Float:x, Float:y, Float:z
GetPlayerPos(playerid,x,y,z);
CreateExplosion(x,y,z,12, 10.0);
SendClientMessage(playerid, -1, "Trapped LOL.");
return 1;
}
new IsInVeh[MAX_PLAYERS];
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
if(GetVehicleModel(vehicleid) == your id)
{
SetTimerEx("Message", 5000, false, "i", playerid);
IsInVeh[playerid] = 1;
}
return 1;
}
public OnPlayerExitVehicle(playerid, vehicleid)
{
IsInVeh[playerid] = 0;
return 1;
}
forward Message(playerid);
public Message(playerid)
{
SendClientMessage(playerid, -1, "Welcome to the vehicle.");
SetTimerEx("Explosion", 5000, false, "i", playerid);
return 1;
}
forward Explosion(playerid);
public Explosion(playerid)
{
if(IsInVeh[playerid] = 1)
{
new Float:x, Float:y, Float:z
GetPlayerPos(playerid,x,y,z);
CreateExplosion(x,y,z,12, 10.0);
SendClientMessage(playerid, -1, "Trapped LOL.");
}
return 1;
}
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger) { vehid = GetVehicleModel(vehicleid); if(vehid == 400 | 405 | 409 | 415 | 418 | 419 | 427 | 440 | 451 | 466) { SetTimerEx("Message", 20000, false, "i", playerid); } return 1; } forward Message(playerid); public Message(playerid) { SendClientMessage(playerid, -1, "[BEEP - BEEP - BEEP]"); SetTimerEx("Explosion", 25000, false, "i", playerid); return 1; } forward Explosion(playerid); public Explosion(playerid) { SetVehicleHealth(vehid, 200); return 1; }
new IsInVeh[MAX_PLAYERS];
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
if(GetVehicleModel(vehicleid) == your id)
{
SetTimerEx("Message", 5000, false, "i", playerid);
IsInVeh[playerid] = 1;
}
return 1;
}
public OnPlayerExitVehicle(playerid, vehicleid)
{
IsInVeh[playerid] = 0;
return 1;
}
forward Message(playerid);
public Message(playerid)
{
SendClientMessage(playerid, -1, "Welcome to the vehicle.");
SetTimerEx("Explosion", 5000, false, "i", playerid);
return 1;
}
forward Explosion(playerid);
public Explosion(playerid)
{
if(IsInVeh[playerid] = 1)
{
new pveh =GetPlayerVehicleID(playerid);
new Float:x, Float:y, Float:z
GetVehiclePos(pveh, x, y, z);
CreateExplosion(x,y,z,12, 10.0);
SendClientMessage(playerid, -1, "Trapped LOL.");
}
return 1;
}
#define YOUR_VEHICLE_MODEL X new ExplodeTimer[MAX_PLAYERS]; new bool:IsPlayerInExplodeVehicle[MAX_PLAYERS]; public OnPlayerStateChange(playerid, newstate, oldstate) { if(oldstate == PLAYER_STATE_ONFOOT && newstate == PLAYER_STATE_DRIVER) { new VehicleID = GetPlayerVehicleID(playerid); if(GetVehicleModel(VehicleID) == YOUR_VEHICLE_MODEL) { IsPlayerInExplodeVehicle[playerid] = true; ExplodeTimer[playerid] = SetTimerEx("ShowExplodeMessage", 20000, false, "i", playerid); } } if(oldstate == PLAYER_STATE_DRIVER && IsPlayerInExplodeVehicle[playerid] == true) { IsPlayerInExplodeVehicle[playerid] = false; KillTimer(ExplodeTimer[playerid]); } return 1; } forward ShowExplodeMessage(playerid); public ShowExplodeMessage(playerid) { if(IsPlayerInExplodeVehicle[playerid] == true) { SendClientMessage(playerid, -1, "Your Message Here"); ExplodeTimer[playerid] = SetTimerEx("ExplodeVehicle", 5000, false, "i", playerid); } return 1; } forward ExplodeVehicle(playerid); public ExplodeVehicle(playerid) { if(IsPlayerInExplodeVehicle[playerid] == true) { new pVehicleID = GetPlayerVehicleID(playerid) SetVehicleHealth(pVehicleID, 0.0); IsPlayerInExplodeVehicle[playerid] = false; } return 1; }
Please DON'T Use OnPlayerEnterVehicle In This case...
i'll Give you an example look at it and learn how i used timers, variables and SAMP functions from Wiki https://sampwiki.blast.hk/wiki/OnPlayerStateChange https://sampwiki.blast.hk/wiki/GetVehicleModel https://sampwiki.blast.hk/wiki/SetVehicleHealth Код:
#define YOUR_VEHICLE_MODEL X new ExplodeTimer[MAX_PLAYERS]; new bool:IsPlayerInExplodeVehicle[MAX_PLAYERS]; public OnPlayerStateChange(playerid, newstate, oldstate) { if(oldstate == PLAYER_STATE_ONFOOT && newstate == PLAYER_STATE_DRIVER) { new VehicleID = GetPlayerVehicleID(playerid); if(GetVehicleModel(VehicleID) == YOUR_VEHICLE_MODEL) { IsPlayerInExplodeVehicle[playerid] = true; ExplodeTimer[playerid] = SetTimerEx("ShowExplodeMessage", 20000, false, "i", playerid); } } if(oldstate == PLAYER_STATE_DRIVER && IsPlayerInExplodeVehicle[playerid] == true) { IsPlayerInExplodeVehicle[playerid] = false; KillTimer(ExplodeTimer[playerid]); } return 1; } forward ShowExplodeMessage(playerid); public ShowExplodeMessage(playerid) { if(IsPlayerInExplodeVehicle[playerid] == true) { SendClientMessage(playerid, -1, "Your Message Here"); ExplodeTimer[playerid] = SetTimerEx("ExplodeVehicle", 5000, false, "i", playerid); } return 1; } forward ExplodeVehicle(playerid); public ExplodeVehicle(playerid) { if(IsPlayerInExplodeVehicle[playerid] == true) { new pVehicleID = GetPlayerVehicleID(playerid) SetVehicleHealth(pVehicleID, 0.0); IsPlayerInExplodeVehicle[playerid] = false; } return 1; } good luck |
Thanks! I only get this error when I compile:
error 001: expected token: ";", but found "-identifier-" |