SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help

Reply
 
Thread Tools Display Modes
Old 12/02/2013, 07:07 PM   #1
Phil_Cutcliffe
Huge Clucker
 
Phil_Cutcliffe's Avatar
 
Join Date: Dec 2011
Location: United Kingdom, London
Posts: 337
Reputation: 7
Default /sellitem [PlayerID] [Item] [Price] - help

Hello I have a /sellitem command which is used for selling items to another player.. In this case WEAPONS

Here is the /sellitem command

Code:
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

Code:
	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! =]

Last edited by Phil_Cutcliffe; 12/02/2013 at 08:24 PM.
Phil_Cutcliffe is offline   Reply With Quote
Old 12/02/2013, 10:42 PM   #2
Phil_Cutcliffe
Huge Clucker
 
Phil_Cutcliffe's Avatar
 
Join Date: Dec 2011
Location: United Kingdom, London
Posts: 337
Reputation: 7
Default Re: Item selling for $1 and not specified price [solved]

-bump any ideas on this please?

Last edited by Phil_Cutcliffe; 13/02/2013 at 02:05 AM.
Phil_Cutcliffe is offline   Reply With Quote
Old 03/06/2013, 10:28 AM   #3
MrVicky
Little Clucker
 
Join Date: Apr 2013
Posts: 14
Reputation: 0
Default Re: /sellitem [PlayerID] [Item] [Price] - help

......
MrVicky is offline   Reply With Quote
Old 03/06/2013, 11:07 AM   #4
Vince
Spam Machine
 
Vince's Avatar
 
Join Date: Sep 2007
Location: Belgium
Posts: 10,094
Reputation: 2655
Default Re: Item selling for $1 and not specified price

The "tmp" variable still contains the playerid when you perform strval on it. I recommend you switch to sscanf.
__________________
Vince is offline   Reply With Quote
Old 03/06/2013, 07:14 PM   #5
MrVicky
Little Clucker
 
Join Date: Apr 2013
Posts: 14
Reputation: 0
Default Re : Item selling for $1 and not specified price

........

Last edited by MrVicky; 11/03/2014 at 10:47 PM.
MrVicky is offline   Reply With Quote
Old 03/06/2013, 07:17 PM   #6
MrVicky
Little Clucker
 
Join Date: Apr 2013
Posts: 14
Reputation: 0
Smile Re : Item selling for $1 and not specified price

.......

Last edited by MrVicky; 11/03/2014 at 10:47 PM.
MrVicky is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
If a player is selling an item? RLGaming Scripting Help 2 07/10/2012 01:06 AM
/sell [item] [amount] [price] iGetty Scripting Help 2 05/02/2012 09:23 PM
how do i set a car price? sbulletin Help Archive 7 06/10/2010 03:35 PM
Is that price ok? AiVAMAN Everything and Nothing 9 23/09/2009 06:44 PM
Price! addysnow1 Help Archive 6 13/09/2009 06:55 PM


All times are GMT. The time now is 06:30 PM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.