Seatbelt Command -
ghzspark - 22.02.2013
So, I need a seatbelt command. I'll show you some things that I would like the command to do:
- /seatbelt command will send a message to the player, something like "You put your seatbelt on" ;
- /seatbelt again will send a message to the player, something like "You put your seatbelt off" ;
- /checkseatbelt will check if the player has the seatbelt on;
- /seatbelt when a player isn't in the vehicle will tell him that he needs to be in a vehicle.
- You can't leave the car with your seatbelt on, and the player will be alerted that he has to put his seatbelt off for leaving the car ( optional ).
thanks.
Re: Seatbelt Command -
Mr.Anonymous - 22.02.2013
You should not request a code here. Ask for it here:
https://sampforum.blast.hk/showthread.php?tid=413556
Re: Seatbelt Command -
Nivniv2 - 22.02.2013
Wrong thread man, check sticky threads.
anyway.
Код:
CMD:sb(playerid, params[]) return cmd_seatbelt(playerid, params);
CMD:seatbelt(playerid, params[])
{
if(IsPlayerInAnyVehicle(playerid) == 0)
{
SendClientMessageEx(playerid, COLOR_GRAD2, "You are not in a vehicle!");
return 1;
}
new string[50 + MAX_PLAYER_NAME];
if(IsPlayerInAnyVehicle(playerid) == 1 && Seatbelt[playerid] == 0)
{
Seatbelt[playerid] = 1;
if(IsABike(GetPlayerVehicleID(playerid)))
{
format(string, sizeof(string), "* %s reaches for their helmet, and puts it on.", GetPlayerNameEx(playerid));
SendClientMessageEx(playerid, COLOR_WHITE, "You have put on your helmet.");
}
else
{
format(string, sizeof(string), "* %s reaches for their seatbelt, and buckles it up.", GetPlayerNameEx(playerid));
SendClientMessageEx(playerid, COLOR_WHITE, "You have put on your seatbelt.");
}
}
else if(IsPlayerInAnyVehicle(playerid) == 1 && Seatbelt[playerid] == 1)
{
Seatbelt[playerid] = 0;
if(IsABike(GetPlayerVehicleID(playerid)))
{
format(string, sizeof(string), "* %s reaches for their helmet, and takes it off.", GetPlayerNameEx(playerid));
SendClientMessageEx(playerid, COLOR_WHITE, "You have taken off your helmet.");
}
else
{
format(string, sizeof(string), "* %s reaches for their seatbelt, and unbuckles it.", GetPlayerNameEx(playerid));
SendClientMessageEx(playerid, COLOR_WHITE, "You have taken off your seatbelt.");
}
}
ProxDetector(30.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
return 1;
}
CMD:cb(playerid, params[]) return cmd_checkbelt(playerid, params);
CMD:checkbelt(playerid, params[])
{
new giveplayerid;
if(sscanf(params, "u", giveplayerid)) return SendClientMessageEx(playerid, COLOR_WHITE, "USAGE: /checkbelt [playerid]");
if(GetPlayerState(giveplayerid) == PLAYER_STATE_ONFOOT)
{
SendClientMessageEx(playerid,COLOR_GREY,"That player is not in any vehicle!");
return 1;
}
if (ProxDetectorS(9.0, playerid, giveplayerid))
{
new string[128];
new stext[4];
if(Seatbelt[giveplayerid] == 0) { stext = "off"; }
else { stext = "on"; }
if(IsABike(GetPlayerVehicleID(playerid)))
{
format(string, sizeof(string), "%s's helmet is currently %s." , GetPlayerNameEx(giveplayerid) , stext);
SendClientMessageEx(playerid,COLOR_WHITE,string);
format(string, sizeof(string), "* %s looks at %s, checking to see if they are wearing a helmet.", GetPlayerNameEx(playerid),GetPlayerNameEx(giveplayerid));
ProxDetector(30.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
}
else
{
format(string, sizeof(string), "%s's seat belt is currently %s." , GetPlayerNameEx(giveplayerid) , stext);
SendClientMessageEx(playerid,COLOR_WHITE,string);
format(string, sizeof(string), "* %s peers through the window at %s, checking to see if they are wearing a seatbelt.", GetPlayerNameEx(playerid),GetPlayerNameEx(giveplayerid));
ProxDetector(30.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
}
}
else { SendClientMessageEx(playerid, COLOR_GREY, "You are not around that player!"); }
return 1;
}
Re: Seatbelt Command -
ghzspark - 22.02.2013
pawn Код:
C:\Users\Mihai\Desktop\samp\Romanian Project Roleplay\gamemodes\ZRP.pwn(23698) : error 017: undefined symbol "SendClientMessageEx"
C:\Users\Mihai\Desktop\samp\Romanian Project Roleplay\gamemodes\ZRP.pwn(23702) : error 017: undefined symbol "Seatbelt"
C:\Users\Mihai\Desktop\samp\Romanian Project Roleplay\gamemodes\ZRP.pwn(23702) : warning 215: expression has no effect
C:\Users\Mihai\Desktop\samp\Romanian Project Roleplay\gamemodes\ZRP.pwn(23702) : error 001: expected token: ";", but found "]"
C:\Users\Mihai\Desktop\samp\Romanian Project Roleplay\gamemodes\ZRP.pwn(23702) : error 029: invalid expression, assumed zero
C:\Users\Mihai\Desktop\samp\Romanian Project Roleplay\gamemodes\ZRP.pwn(23702) : fatal error 107: too many error messages on one line
Compilation aborted.Pawn compiler 3.2.3664 Copyright (c) 1997-2006, ITB CompuPhase
5 Errors.
23698 line
pawn Код:
SendClientMessageEx(playerid, COLOR_GRAD2, "You're not in a vehicle!");
23702 line
pawn Код:
if(IsPlayerInAnyVehicle(playerid) == 1 && Seatbelt[playerid] == 0)
what's wrong?
Re: Seatbelt Command -
ghzspark - 24.02.2013
bump
Re: Seatbelt Command -
Jstylezzz - 24.02.2013
change
pawn Код:
SendClientMessageEx(playerid, COLOR_GRAD2, "You're not in a vehicle!");
to
pawn Код:
SendClientMessage(playerid, COLOR_GRAD2, "You're not in a vehicle!");
and
pawn Код:
if(IsPlayerInAnyVehicle(playerid) == 1 && Seatbelt[playerid] == 0)
to
pawn Код:
if(IsPlayerInAnyVehicle(playerid) && Seatbelt[playerid] == 0)
I have a seatbelt command too, and mines has the above things, which work..
Re: Seatbelt Command -
Da_Noob - 24.02.2013
And you also need to make a global variable called seatbelt... seriously I hate it when people just copy-paste codes they find on the forums.
Re: Seatbelt Command -
ghzspark - 25.02.2013
i'm not copying , im trying to learn , my code didn't worked so i wanted to find out what's the problem
btw, same errors
Re: Seatbelt Command -
lean1337 - 25.02.2013
add new Seatbelt[MAX_PLAYERS]; somewhere in ur script.
Re: Seatbelt Command -
ghzspark - 26.02.2013
26 errors now.