Turn command into MMB (Middle Mouse Click) -
Ryan50 - 11.09.2015
How can i make this code MMB Key.
Код:
CMD:fine(playerid, params[])
{
new string2[256], Float:x, Float:y, Float:z;
if(GetPlayerTeam(playerid) != TEAM_COP) return SendClientMessage(playerid, COLOUR_RED, "Only Cops can use this command.");
if(!strlen(params)) return SendClientMessage(playerid, -1, "Usage: /ticket [Player Id]");
new player1, playername[MAX_PLAYER_NAME], adminname[MAX_PLAYER_NAME], string[128];
player1 = strval(params);
GetPlayerPos(player1, x,y,z);
if(!IsPlayerConnected(player1) && player1 != INVALID_PLAYER_ID) return SendClientMessage(playerid, -1, "ERROR: Player not found");
if(GetPlayerWantedLevel(player1) <= 1) return SendClientMessage(playerid, -1, "ERROR: This player does not have 1 or more wanted level!");
if(IsPlayerInAnyVehicle(player1)) return SendClientMessage(playerid, -1, "ERROR: Player is in a vehicle!");
if (!IsPlayerInRangeOfPoint(playerid, 5.0, x,y,z) return SendClientMessage(playerid, -1, "ERROR: You need to be close to the player to give him a ticket.");
GetPlayerName(player1, playername, sizeof(playername));
GetPlayerName(playerid, adminname, sizeof(adminname));
format(string,sizeof(string),"Officer %s has given you a ticket.",adminname);
SendClientMessage(player1, -1, string);
SetPVarInt(player1, "Fine", 1);
SetPVarInt(player1, "Issuerid", playerid);
format(string2, sizeof(string2), "Officer %s has given %s a ticket", adminname, playername);
//Copstats[playerid][Tickets]++;
SendClientMessageToAll(-1, string2);
return 1;
}
Re: Turn command into MMB (Middle Mouse Click) -
DarkLored - 11.09.2015
This should answer your questions
https://sampwiki.blast.hk/wiki/OnPlayerKeyStateChange
Re: Turn command into MMB (Middle Mouse Click) -
Spoff - 11.09.2015
https://sampwiki.blast.hk/wiki/Keys - Keys of SA-MP
https://sampwiki.blast.hk/wiki/OnPlayerKeyStateChange - Function how to use that
Код:
public OnPlayerKeyStateChange(playerid,newkeys,oldkeys)
{
if(newkeys & KEY_LOOK_BEHIND) // MMB Key
{
new string2[256], Float:x, Float:y, Float:z;
if(GetPlayerTeam(playerid) != TEAM_COP) return SendClientMessage(playerid, COLOUR_RED, "Only Cops can use this command.");
if(!strlen(params)) return SendClientMessage(playerid, -1, "Usage: /ticket [Player Id]");
new player1, playername[MAX_PLAYER_NAME], adminname[MAX_PLAYER_NAME], string[128];
player1 = strval(params);
GetPlayerPos(player1, x,y,z);
if(!IsPlayerConnected(player1) && player1 != INVALID_PLAYER_ID) return SendClientMessage(playerid, -1, "ERROR: Player not found");
if(GetPlayerWantedLevel(player1) <= 1) return SendClientMessage(playerid, -1, "ERROR: This player does not have 1 or more wanted level!");
if(IsPlayerInAnyVehicle(player1)) return SendClientMessage(playerid, -1, "ERROR: Player is in a vehicle!");
if (!IsPlayerInRangeOfPoint(playerid, 5.0, x,y,z) return SendClientMessage(playerid, -1, "ERROR: You need to be close to the player to give him a ticket.");
GetPlayerName(player1, playername, sizeof(playername));
GetPlayerName(playerid, adminname, sizeof(adminname));
format(string,sizeof(string),"Officer %s has given you a ticket.",adminname);
SendClientMessage(player1, -1, string);
SetPVarInt(player1, "Fine", 1);
SetPVarInt(player1, "Issuerid", playerid);
format(string2, sizeof(string2), "Officer %s has given %s a ticket", adminname, playername);
//Copstats[playerid][Tickets]++;
SendClientMessageToAll(-1, string2);
return 1;
}
}
Re: Turn command into MMB (Middle Mouse Click) -
Ryan50 - 12.09.2015
Код:
(1029) : error 017: undefined symbol "params"
(1031) : error 017: undefined symbol "params"
(1036) : error 001: expected token: ")", but found "return"
Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase
Line 1036:
if (!IsPlayerInRangeOfPoint(playerid, 5.0, x,y,z) return SendClientMessage(playerid, -1, "ERROR: You need to be close to the player to give him a ticket.");
3 Errors.
Код:
public OnPlayerKeyStateChange(playerid,newkeys,oldkeys)
{
if(newkeys & KEY_LOOK_BEHIND)
{
new string2[256], Float:x, Float:y, Float:z;
if(GetPlayerTeam(playerid) != TEAM_COP) return SendClientMessage(playerid, COLOUR_RED, "Only Cops can use this command.");
if(!strlen(params)) return SendClientMessage(playerid, -1, "Usage: /ticket [Player Id]");
new player1, playername[MAX_PLAYER_NAME], adminname[MAX_PLAYER_NAME], string[128];
player1 = strval(params);
GetPlayerPos(player1, x,y,z);
if(!IsPlayerConnected(player1) && player1 != INVALID_PLAYER_ID) return SendClientMessage(playerid, -1, "ERROR: Player not found");
if(GetPlayerWantedLevel(player1) <= 1) return SendClientMessage(playerid, -1, "ERROR: This player does not have 1 or more wanted level!");
if(IsPlayerInAnyVehicle(player1)) return SendClientMessage(playerid, -1, "ERROR: Player is in a vehicle!");
if (!IsPlayerInRangeOfPoint(playerid, 5.0, x,y,z) return SendClientMessage(playerid, -1, "ERROR: You need to be close to the player to give him a ticket.");
GetPlayerName(player1, playername, sizeof(playername));
GetPlayerName(playerid, adminname, sizeof(adminname));
format(string,sizeof(string),"Officer %s has given you a ticket.",adminname);
SendClientMessage(player1, -1, string);
SetPVarInt(player1, "Fine", 1);
SetPVarInt(player1, "Issuerid", playerid);
format(string2, sizeof(string2), "Officer %s has given %s a ticket", adminname, playername);
//Copstats[playerid][Tickets]++;
SendClientMessageToAll(-1, string2);
}
return 1;
}
Re: Turn command into MMB (Middle Mouse Click) -
Ryan50 - 12.09.2015
Bump
Re: Turn command into MMB (Middle Mouse Click) -
DarkLored - 12.09.2015
You can't simply copy paste and not put any effort into working on it in hopes that others will do the work for you.
look at the errors and try to understand the basic English that it implies, it says that 'params' meaning the string that the player has typed is not defined because you are not using the command or you haven't created the variable which you don't need, just convert it to fit the callback, you'll need to detect if a player is next to another player using a function that detects if a player is near another one.
http://dictionary.reference.com/browse/undefined
P.S. Don't bump threads every 2 hours, that way you show an impatient side.
Re: Turn command into MMB (Middle Mouse Click) -
Crayder - 12.09.2015
If this were applied to a key, how do you expect the script to know which player you want to fine? You should add a dialog instead of the parameter check. I'd script it for you but I'm pretty busy atm.