07.11.2013, 11:45
hi all.
my and some friends (6) are working on a new GM.
we are almost 20% done but we are having a problem here.
first , we are using this player inventory include
https://sampforum.blast.hk/showthread.php?tid=130436
what we want to do is a /sell and /accept command.
the commands works , but we have the item name in command params.
sscanf take it there is no problem.
but how do we put the item name (string ) GLOBAL so i can add the item in the inventory of the player that do /accept ?
we already tried pvars with no luck.
here are the code we actually have for that
command /sellitem
command /acceptitem
the id , amount , price are all working perfect as they are Int and stored in enum ( global ).
now how can we do it for a string ( item name , which is text , undefined lenght )
we also tried new thestring[MAX_PLAYERS][30]; and new thestring[MAX_PLAYERS][] = "NULL"; and everything similar with no luck.
you can see we also tried using pvars.
thank you
my and some friends (6) are working on a new GM.
we are almost 20% done but we are having a problem here.
first , we are using this player inventory include
https://sampforum.blast.hk/showthread.php?tid=130436
what we want to do is a /sell and /accept command.
the commands works , but we have the item name in command params.
sscanf take it there is no problem.
but how do we put the item name (string ) GLOBAL so i can add the item in the inventory of the player that do /accept ?
we already tried pvars with no luck.
here are the code we actually have for that
command /sellitem
pawn Код:
CMD:sellitem(playerid, params[])
{
new id;
new itemname[30];
new amount;
new price;
if(sscanf(params, "uiis[30]", id, amount, price, itemname))
{
SendClientMessage(playerid, COLOR_WHITE, "[USAGE] /sellitem [playerid] [amount] [price] [itemname]"); //-1 stands for white, change that with your colors if wanted.
}
else
{
new targetname[MAX_PLAYER_NAME];
new playername[MAX_PLAYER_NAME];
new string[128];
new string2[128];
GetPlayerName(id,targetname,sizeof(targetname));
GetPlayerName(playerid,playername,sizeof(playername));
Player[id][AmountHD] = amount;
Player[id][PriceHD] = price;
format(string, sizeof(string), "Player {808000}%s{FFFFFF}(%i) want to sell you %i %s for $%i. Use /acceptitem [sellerid] to accept.", playername, playerid, amount, itemname, price);
SetPVarString(id,"ItemToAccept", itemname);
SendClientMessage(id, -1, string);
Player[id][PendingHD] = 1;
Player[playerid][OfferingHD] = 1;
format(string2, sizeof(string2), "Transaction sent to %s(%i)", targetname, id);
SendClientMessage(playerid, -1, string2);
}
return 1;
}
pawn Код:
CMD:acceptitem(playerid, params[])
{
new id;
new itemname[30];
new amount;
new price;
if(sscanf(params, "u", id))
{
SendClientMessage(playerid, COLOR_WHITE, "[USAGE] /acceptitem [seller id]");
}
else
{
new targetname[MAX_PLAYER_NAME];
new playername[MAX_PLAYER_NAME];
GetPlayerName(playerid,playername,sizeof(playername));
GetPlayerName(id,targetname,sizeof(targetname));
new string[128];
amount = Player[id][AmountHD];
price = Player[id][PriceHD];
if(GetPlayerMoney(playerid) <price)
{
SendClientMessage(playerid, COLOR_RED, "Not enought cash.");
Player[playerid][PendingHD] = 0;
Player[id][OfferingHD] = 0;
}
else
{
if(Player[playerid][PendingHD] == 1)
{
if(Player[id][OfferingHD] == 1)
{
GetPVarString(playerid, "ItemToAccept", itemname, 30);
format(string, sizeof(string), "Player %s(%i) accepted the transaction.", playername, playerid);
SendClientMessage(id, COLOR_GREEN, string);
Player[id][PendingHD] = 0;
Player[playerid][OfferingHD] = 0;
AddItem(playerid,itemname,amount);
AC_BS_GivePlayerMoney(playerid, -price);
AC_BS_GivePlayerMoney(id, price);
new string2[128];
format(string2, sizeof(string2), "%i %s have been added to your inventory and $%i have been given to %s(%i)", amount, itemname, price, targetname, id);
SendClientMessage(playerid, COLOR_GREEN, string2);
SendClientMessage(playerid, COLOR_GREEN, itemname);
}
}
}
}
return 1;
}
now how can we do it for a string ( item name , which is text , undefined lenght )
we also tried new thestring[MAX_PLAYERS][30]; and new thestring[MAX_PLAYERS][] = "NULL"; and everything similar with no luck.
you can see we also tried using pvars.
thank you