Help Mats -
SHFaCeBook - 25.11.2014
Hello .
this cmd sellmats , when player is sell mats to player , not get money.
Code:
pawn Код:
CMD:sellmats(playerid, params[])
{
new target, amount, price;
if(sscanf(params, "uii", target, amount, price)) return SCM(playerid, -1, "Syntax: /sellmats [playerid] [amount] [price]");
if(amount <= playerVariables[playerid][pMaterials])
{
if(target != INVALID_PLAYER_ID)
{
if(playerVariables[target][pMoney] >= price)
{
SetPVarInt(target, "mAmount", amount);
SetPVarInt(target, "mPrice", price);
SetPVarInt(target, "mID", playerid);
format(szMessage, sizeof(szMessage), "** %s wish to sell you %d mats for $%i. Type /accept mats if you wish to accept.", playerVariables[playerid][pNormalName], amount, price);
SCM(target, COLOR_LIGHTBLUE, szMessage);
format(szMessage, sizeof(szMessage), "** You wish to sell %d mats to %s, for $%i.", amount, playerVariables[target][pNormalName], price);
SCM(playerid, COLOR_LIGHTBLUE, szMessage);
}
else
{
SCM(playerid, -1, "This player does not have enough money for this mats!");
}
}
else
{
SCM(playerid, -1, "Player not connected.");
}
}
else
{
SCM(playerid, -1, "You don't have enough mats.");
}
return 1;
}
+rep for any helped me, Thanks.
Re: Help Mats -
dusk - 25.11.2014
Show us /accept mats command.
Re: Help Mats -
SHFaCeBook - 25.11.2014
Quote:
Originally Posted by dusk
Show us /accept mats command.
|
pawn Код:
else if(strcmp(params, "mats", true) == 0)
{
if(GetPVarInt(playerid, "mID") >= 0)
{
new amount, dealer, price;
amount = GetPVarInt(playerid, "mAmount");
price = GetPVarInt(playerid, "mPrice");
dealer = GetPVarInt(playerid, "mID");
if(IsPlayerConnected(dealer))
{
playerVariables[playerid][pMoney] -= price;
playerVariables[playerid][pMaterials] += amount;
playerVariables[dealer][pMaterials] -= amount;
format(szMessage, sizeof(szMessage), "You have bought %d mats from %s for $%i", amount, playerVariables[dealer][pNormalName], price);
SCM(playerid, COLOR_LIGHTBLUE, szMessage);
format(szMessage, sizeof(szMessage), "%s has bought %d mats from you, for $%i." , playerVariables[playerid][pNormalName], amount, price);
SCM(dealer, COLOR_LIGHTBLUE, szMessage);
}
else
{
SCM(playerid, -1, "This player is not connected!");
DeletePVar(playerid, "mAmount");
DeletePVar(playerid, "mID");
DeletePVar(playerid, "mPrice");
}
}
else
{
SCM(playerid, -1, "You don't have an active mats offer.");
}
}
else SendClientMessage(playerid, COLOR_GREY, "Invalid item specified.");
Re: Help Mats -
SHFaCeBook - 25.11.2014
Bumb
Re: Help Mats -
SHFaCeBook - 26.11.2014
Bumb
Re: Help Mats -
Jonesy96 - 26.11.2014
At no point do you actually give the player money in game.
Ad the following to your accept command where you send the client message to say they've bought the mat.
Код:
GivePlayerMoney(playerid, amount);