/sellitem [PlayerID] [Item] [Price] - help -
Phil_Cutcliffe - 12.02.2013
Hello I have a /sellitem command which is used for selling items to another player.. In this case WEAPONS
Here is the /sellitem command
Код:
if(strcmp(cmd, "/sellitem", true) == 0)
{
tmp = strtok(cmdtext, idx);
if(!strlen(tmp))
{
SendClientMessage(playerid,COLOR_SYSTEM,"[CMDINFO]: /sellitem [Players ID] [Gun/Item] [Price]");
return 1;
}
giveplayerid = ReturnUser(tmp);
if(IsPlayerConnected(giveplayerid))
{
if(giveplayerid != INVALID_PLAYER_ID)
{
new price = strval(tmp);
if(giveplayerid == playerid)
{
SendClientMessage(playerid, COLOR_SYSTEM, "You cannot sell an item to yourself!");
return 1;
}
if (ProxDetectorS(3.0, playerid, giveplayerid))
{
new weapon = GetPlayerWeapon(playerid);
if(weapon == 22)
{
if(PlayerInfo[playerid][pMats] < 400)
{
SendClientMessage(playerid, COLOR_SYSTEM, "You don't have enough materials (400)");
return 1;
}
OfferWeaponPlayer[giveplayerid] = playerid;
OfferWeaponPrice[giveplayerid] = price;
OfferedWeapon[giveplayerid] = 1;
format(string, sizeof(string), "%s has offered you a 9mm for $%d (( /acceptitem ))", GetPlayerNameEx(playerid), price);
SendClientMessage(giveplayerid, COLOR_SYSTEM, string);
format(string, sizeof(string), "You offered a 9mm to %s for $%d", GetPlayerNameEx(giveplayerid), price);
SendClientMessage(playerid, COLOR_SYSTEM, string);
return 1;
}
This is just the first gun example shown.. For some reason though when I sell the gun for say... $20000 it still just sells for $1 .... Where am I going wrong here?
Here is the /acceptitem command which the player who is being SOLD the WEAPON must use
Код:
if(strcmp("/acceptitem", cmd, true) == 0)
{
if(OfferedWeapon[playerid] == 1)
{
if(GetPlayerCash(playerid) >= OfferWeaponPrice[playerid])
{
if (ProxDetectorS(15.0, playerid, OfferWeaponPlayer[playerid]))
{
new weapon = GetPlayerWeapon(giveplayerid);
if(weapon == 22)
{
format(string, sizeof(string), "%s has bought the 9mm from you for $%d.", GetPlayerNameEx(playerid), OfferWeaponPrice[playerid]);
SendClientMessage(OfferHotdogPlayer[playerid], COLOR_SYSTEM, string);
format(string, sizeof(string), "You have bought the 9mm from %s for $%d.", GetPlayerNameEx(OfferWeaponPlayer[playerid]), OfferWeaponPrice[playerid]);
SendClientMessage(playerid, COLOR_SYSTEM, string);
GivePlayerCash(OfferWeaponPlayer[playerid], OfferWeaponPrice[playerid]);
GivePlayerCash(playerid, -OfferWeaponPrice[playerid]);
PlayerInfo[giveplayerid][pMats] -= 400;
PlayerInfo[giveplayerid][pCguns] += 1;
GivePlayerWeapon(playerid, 22, 9999999);
PlayerInfo[playerid][p9mm] = 1;
PlayerInfo[playerid][pGun1] = 22;
PlayerInfo[playerid][pAmmo1] = 9999999;
}
Above is just ONE example of my /acceptitem command code
Any help would be greatly appreciated! =]
Re: Item selling for $1 and not specified price [solved] -
Phil_Cutcliffe - 12.02.2013
-bump any ideas on this please?
Re: /sellitem [PlayerID] [Item] [Price] - help -
MrVicky - 03.06.2013
......
Re: Item selling for $1 and not specified price -
Vince - 03.06.2013
The "tmp" variable still contains the playerid when you perform strval on it. I recommend you switch to sscanf.
Re : Item selling for $1 and not specified price -
MrVicky - 03.06.2013
........
Re : Item selling for $1 and not specified price -
MrVicky - 03.06.2013
.......