A small 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)
+---- Forum: Help Archive (
https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: A small problem!!! (
/showthread.php?tid=263949)
A small problem!!! -
Cjgogo - 24.06.2011
Can someone tell me what's wrong here?No compiling errors,simply non-wrokage on game.
pawn Код:
new gBreakDown[MAX_PLAYERS];
public OnPlayerConnect(playerid)
{
gBreakDown[playerid] = 0;
return 1;
}
public OnPlayerUpdate(playerid)
{
new vehicleid = GetPlayerVehicleID(playerid);
if(IsPlayerInAnyVehicle(playerid) && vehicleid == 437 && GetPlayerSpeed(playerid) > 60 && gBreakDown[playerid] == 0)
{
gBreakDown[playerid] = 1;
SendClientMessage(playerid,COLOR_RED,"A bomb has been planted in your bus and if you slow down below 40 km/h,you'll be blwoed up");
}
if(IsPlayerInAnyVehicle(playerid) && vehicleid == 437 && gBreakDown[playerid] == 1 && GetPlayerSpeed(playerid) < 41)
{
gBreakDown[playerid] = 0;
SendClientMessage(playerid,COLOR_RED,"You didn't obey the rule,BYE BYE!!!");
SetVehicleHealth(vehicleid,0);
}
return 1;
}
stock GetPlayerSpeed(playerid, bool:kmh = true)
{
new
Float:xx,
Float:yy,
Float:zz,
Float:pSpeed;
if(IsPlayerInAnyVehicle(playerid))
{
GetVehicleVelocity(GetPlayerVehicleID(playerid),xx,yy,zz);
}
else
{
GetPlayerVelocity(playerid,xx,yy,zz);
}
pSpeed = floatsqroot((xx * xx) + (yy * yy) + (zz * zz));
return kmh ? floatround((pSpeed * 195.12)) : floatround((pSpeed * 121.9));
}
Re: A small problem!!! -
Cjgogo - 24.06.2011
Anyone?
Re: A small problem!!! -
Babul - 24.06.2011
to check for the vehicle types (id), you need the GetVehicleModel(vehicleid) , maybe you need to include a GetVehicleSpeed?
Код:
public OnPlayerUpdate(playerid)
{
new vehicleid = GetPlayerVehicleID(playerid);
new modelid= GetVehicleModel(vehicleid);
if(IsPlayerInAnyVehicle(playerid) && modelid == 437 && GetPlayerSpeed(playerid) > 60 && gBreakDown[playerid] == 0)
{
gBreakDown[playerid] = 1;
SendClientMessage(playerid,COLOR_RED,"A bomb has been planted in your bus and if you slow down below 40 km/h,you'll be blowed up");
}
if(IsPlayerInAnyVehicle(playerid) && modelid == 437 && gBreakDown[playerid] == 1 && GetPlayerSpeed(playerid) < 41)
{
gBreakDown[playerid] = 0;
SendClientMessage(playerid,COLOR_RED,"You didn't obey the rule,BYE BYE!!!");
SetVehicleHealth(vehicleid,0);
}
return 1;
}
Re: A small problem!!! -
Cjgogo - 24.06.2011
Nope,still not working,any other sugesstions(I tried this a few months ago and I saw it's not working BUT THIS TIME I WON'T GIVE UP)?
Re: A small problem!!! -
Cjgogo - 24.06.2011
What's the problem?I changed GetPlayerVehicleID with GetVehicleModel and still not working?
Re: A small problem!!! -
Vince - 24.06.2011
GetVehicleModel(GetPlayerVehicleID(playerid));
Also you do not need to call IsPlayerInAnyVehicle if you already retrieved the vehicleid.