Handbrake for vehicles.
Under all your define's etc. put this:
Код:
forward handbrake(playerid);
OnPlayerCommandText:
Код:
if(strcmp(cmdtext, "/hb", true) == 0)
{
if(IsPlayerInAnyVehicle(playerid)) {
TogglePlayerControllable(playerid,0);
GameTextForPlayer(playerid,"~r~HANDBRAKE!!",1500,3);
SetTimer("handbrake",1000,false);
}
else {
SendClientMessage(playerid,0xAA3333AA,"You're not in a vehicle");
return 1;
}
}
A whole new function, outside any public()
Код:
public handbrake(playerid)
{
TogglePlayerControllable(playerid,1);
}
What does it do?:
If you're inside a car this function will freeze you for 1 second, then unfreeze again. This will make the vehicle brake in 1 second, which could be used as a handbrake.
If you're not inside a car it will just return "You're not in a vehicle"
Attach/Detach a map icon to yourself
Place this under your define's etc.
Код:
forward marker(playerid); // Timer to keep updating the player's location
new mapicon; // This will be used to KillTimer on /hide
OnPlayerCommandText:
Код:
if(strcmp(cmdtext, "/show", true) == 0)
{
SetPlayerMapIcon(playerid,1,x,y,z,22,0); // Will attach the icon to the player
SendClientMessage(playerid,0xB360FDFF,"You're now visible on the radar");
mapicon = SetTimer("marker",1,true); // Timer to keep updating the player's location
}
Код:
if(strcmp(cmdtext, "/hide", true) == 0)
{
RemovePlayerMapIcon(playerid,1); // Will detach the icon from the player
SendClientMessage(playerid,0xB360FDFF,"You're not visible on the radar anymore");
KillTimer(mapicon); // Will kill the timer so it won't update the location anymore
}
Then place this outside any function:
Код:
public marker(playerid)
{
new Float:x, Float:y, Float:z;
GetPlayerPos(playerid, x, y, z); // Will get the player's location
SetPlayerMapIcon(playerid,1,x,y,z,22,0); // Will place the icon on the player all the time
}
What does it do?:
/show will attach a map icon to yourself, in this case it will attach this icon:
You can change this icon by looking at this line:
Код:
SetPlayerMapIcon(playerid,1,x,y,z,22,0); // Will attach the icon to the player
and this on public marker:
Код:
SetPlayerMapIcon(playerid,1,x,y,z,22,0); // Will place the icon on the player all the time
Change the number "22" to the icon ID you want to attach. (Look at the bottom of this page:
https://sampwiki.blast.hk/wiki/SetPlayerMapIcon)
It uses a timer to keep updating the player's location and attach the map icon to the player all the time, you can remove it with /hide