Problem /repair command - 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)
+--- Thread: Problem /repair command (
/showthread.php?tid=536351)
Problem /repair command -
buburuzu19 - 09.09.2014
Mechanics can repair themself , how can i fix this ?
Code:
pawn Код:
CMD:repair(playerid,params[])
{
new userID;
new giveplayer[MAX_PLAYER_NAME];
new sendername[MAX_PLAYER_NAME];
new moneys, string[256];
if(IsPlayerConnected(playerid))
{
if(playerVariables[playerid][pJob] != 3)
{
SendClientMessage(playerid, COLOR_GREY, "You are not a mechanic.");
return 1;
}
if(sscanf(params, "ui", userID, moneys))
{
return SendClientMessage(playerid, COLOR_GREY, SYNTAX_MESSAGE"/repair [playerid] [money]");
}
if(moneys < 1 || moneys > 15000) { SendClientMessage(playerid, COLOR_GREY, "The money must be until 15000$."); return 1; }
if(IsPlayerConnected(userID))
{
if(userID != INVALID_PLAYER_ID)
{
if(IsPlayerInAnyVehicle(userID))
{
GetPlayerName(userID, giveplayer, sizeof(giveplayer));
GetPlayerName(playerid, sendername, sizeof(sendername));
format(string, sizeof(string), "You offerd %s to fix his car for $%d.",giveplayer,moneys);
SendClientMessage(playerid, COLOR_WHITE, string);
format(string, sizeof(string), " Car Mechanic %s wants to repair your car for $%d,(type /accept repair to accept).",sendername,moneys);
SendClientMessage(userID, COLOR_WHITE, string);
RepairOffer[userID] = playerid;
RepairPrice[userID] = moneys;
}
}
}
}
return 1;
}
Re: Problem /repair command -
Threshold - 09.09.2014
pawn Код:
CMD:repair(playerid,params[])
{
if(!IsPlayerConnected(playerid)) return 1;
if(playerVariables[playerid][pJob] != 3) return SendClientMessage(playerid, COLOR_GREY, "You are not a mechanic.");
new userID, moneys;
if(sscanf(params, "ui", userID, moneys)) return SendClientMessage(playerid, COLOR_GREY, SYNTAX_MESSAGE"/repair [playerid] [money]");
if(!(0 < moneys < 15001)) return SendClientMessage(playerid, COLOR_GREY, "The money must be between $1 and $15000.");
if(!IsPlayerConnected(userID) || userID == INVALID_PLAYER_ID) return SendClientMessage(playerid, COLOR_GREY, "User is not connected.");
if(userID == playerid) return SendClientMessage(playerid, COLOR_GREY, "You cannot offer services to yourself.");
if(!IsPlayerInAnyVehicle(userID)) return SendClientMessage(playerid, COLOR_GREY, "This player is not in a vehicle.");
new giveplayer[MAX_PLAYER_NAME], string[110];
GetPlayerName(userID, giveplayer, sizeof(giveplayer));
format(string, sizeof(string), "You offered to fix %s's car for $%d.", giveplayer, moneys);
SendClientMessage(playerid, COLOR_WHITE, string);
GetPlayerName(playerid, giveplayer, sizeof(giveplayer));
format(string, sizeof(string), " Car Mechanic %s wants to repair your car for $%d,(type /accept repair to accept).", giveplayer, moneys);
SendClientMessage(userID, COLOR_WHITE, string);
RepairOffer[userID] = playerid;
RepairPrice[userID] = moneys;
return 1;
}
EDIT:
This line will check if the ID that you entered (userID) is the same as the ID of the player who typed the command (playerid), A.K.A. you.