[CMD] Sellgun problem
#1

My sellgun command doesn't work at all and i can't figure it out.

This are my sellgun and accept weapon commands

Код:
CMD:sellgun(playerid, params[]) {
	new
		id,
		weapon,
		weaponname[25],
		weaponprice;

	if(sscanf(params, "us[25]i", id, weapon, weaponprice))
	{
		SCM(playerid, COLOR_GREY, SYNTAX_MESSAGE"/sellgun [playerid] [weapon name] [price]");
		SCM(playerid, COLOR_GREY, "Available weapon names: rifle, m4, deagle, ak47");
	}
	else if(playerVariables[playerid][pJob] == 1)
	{
		if(id != INVALID_PLAYER_ID)
		{
	   	    if(weaponprice > 0)
			{
    			new Float:X, Float:Y, Float:Z;
				GetPlayerPos(playerid, X,Y,Z);
				if(IsPlayerInRangeOfPoint(playerid, 20, X, Y, Z))
				{
					if(strcmp(weaponname, "m4", true) == 0)
					{
						GetPlayerName(id, szPlayerName, MAX_PLAYER_NAME);
						format(szMessage, sizeof(szMessage), "You have offered %s a M4 for $%i", szPlayerName, weaponprice);
						SCM(playerid, COLOR_WHITE, szMessage);

						GetPlayerName(playerid, szPlayerName, MAX_PLAYER_NAME);
						format(szMessage, sizeof(szMessage), "%s has offered you a M4 for $%i. To accept type /accept weapon", szPlayerName, weaponprice);
						SCM(id, COLOR_NICESKY, szMessage);

						SetPVarInt(id,"gunID",playerid);
						SetPVarInt(playerid,"gun",31);
						SetPVarInt(playerid,"slot",GetWeaponSlot(31));
						SetPVarInt(id,"gunPrice",weaponprice);
						SetPVarInt(id,"matsprice", 5000);
					}
					else if(strcmp(weaponname, "rifle", true) == 0)
					{
						GetPlayerName(id, szPlayerName, MAX_PLAYER_NAME);
						format(szMessage, sizeof(szMessage), "You have offered %s a Rifle for $%i", szPlayerName, weaponprice);
						SCM(playerid, COLOR_WHITE, szMessage);

						GetPlayerName(playerid, szPlayerName, MAX_PLAYER_NAME);
						format(szMessage, sizeof(szMessage), "%s has offered you a Rifle for $%i. To accept type /accept weapon", szPlayerName, weaponprice);
						SCM(id, COLOR_NICESKY, szMessage);

						SetPVarInt(id,"gunID",playerid);
						SetPVarInt(playerid,"gun",33);
						SetPVarInt(playerid,"slot",GetWeaponSlot(33));
						SetPVarInt(id,"gunPrice",weaponprice);
						SetPVarInt(id,"matsprice", 5000);
					}
					else if(strcmp(weaponname, "ak47", true) == 0)
					{
						GetPlayerName(id, szPlayerName, MAX_PLAYER_NAME);
						format(szMessage, sizeof(szMessage), "You have offered %s an AK47 for $%i", szPlayerName, weaponprice);
						SCM(playerid, COLOR_WHITE, szMessage);

						GetPlayerName(playerid, szPlayerName, MAX_PLAYER_NAME);
						format(szMessage, sizeof(szMessage), "%s has offered you an AK47 for $%i. To accept type /accept weapon", szPlayerName, weaponprice);
						SCM(id, COLOR_NICESKY, szMessage);

						SetPVarInt(id,"gunID",playerid);
						SetPVarInt(playerid,"gun",30);
						SetPVarInt(playerid,"slot",GetWeaponSlot(30));
						SetPVarInt(id,"gunPrice",weaponprice);
						SetPVarInt(id,"matsprice", 5000);
					}
					else if(strcmp(weaponname, "deagle", true) == 0)
					{
						GetPlayerName(id, szPlayerName, MAX_PLAYER_NAME);
						format(szMessage, sizeof(szMessage), "You have offered %s a Deagle for $%i", szPlayerName, weaponprice);
						SCM(playerid, COLOR_WHITE, szMessage);

						GetPlayerName(playerid, szPlayerName, MAX_PLAYER_NAME);
						format(szMessage, sizeof(szMessage), "%s has offered you a Deagle for $%i. To accept type /accept weapon", szPlayerName, weaponprice);
						SCM(id, COLOR_NICESKY, szMessage);

						SetPVarInt(id,"gunID",playerid);
						SetPVarInt(playerid,"gun",24);
						SetPVarInt(playerid,"slot",GetWeaponSlot(24));
						SetPVarInt(id,"gunPrice",weaponprice);
						SetPVarInt(id,"matsprice", 5000);
					}
					else return SCM(playerid,-1,"Invalid weapon name.");
				}
				else SCM(playerid, COLOR_GREY, "You're too far away.");
			}
			else SCM(playerid, COLOR_GREY, "The price must be higher than 0!");
	    }
		else SCM(playerid, COLOR_GREY, "The specified player ID is either not connected or has not authenticated.");
	}
	else SCM(playerid, COLOR_GREY, "You are not an arms dealer");
	return 1;
}
Код:
else if(strcmp(params, "weapon", true) == 0) {

			new
				playerOffering = GetPVarInt(playerid,"gunID"),
				weaponOffering = GetPVarInt(GetPVarInt(playerid,"gunID"),"gun"),
				slotOffering = GetPVarInt(GetPVarInt(playerid,"gunID"),"slot"),
				matsPrice = GetPVarInt(playerid,"matsprice"),
				gunPrice = GetPVarInt(playerid,"gunPrice"),
				WplayerName[2][MAX_PLAYER_NAME],
				wstring[128];

	   		if(weaponOffering != 0 && slotOffering != 0) {
				if(IsPlayerInRangeOfPlayer(playerid, playerOffering, 5.0) && !IsPlayerInAnyVehicle(playerid) && !IsPlayerInAnyVehicle(playerOffering)) {

					if(playerVariables[playerOffering][pFreezeType] > 0) {
						return SendClientMessage(playerid, COLOR_GREY, "That person is cuffed, tazed, or frozen - they can't do this.");
					}
					else if(playerVariables[playerid][pFreezeType] > 0) {
						return SendClientMessage(playerid, COLOR_GREY, "You can't do this while cuffed, tazed, or frozen.");
					}
					else {

						givePlayerValidWeapon(playerid, weaponOffering);


						GetPlayerName(playerOffering, WplayerName[0], MAX_PLAYER_NAME);
						GetPlayerName(playerid, WplayerName[1], MAX_PLAYER_NAME);

						format(wstring, sizeof(wstring), "You have accepted the %s from %s.", WeaponNames[weaponOffering], WplayerName[0]);
						SendClientMessage(playerid, COLOR_WHITE, wstring);

						format(wstring, sizeof(wstring), "%s has accepted the %s you offered them.", WplayerName[1], WeaponNames[weaponOffering]);
						SendClientMessage(playerOffering, COLOR_WHITE, wstring);
						
						playerVariables[playerOffering][pMaterials] -= matsPrice;
						playerVariables[playerid][pMoney] -= gunPrice;
						playerVariables[playerOffering][pMoney] += gunPrice;

						DeletePVar(playerOffering,"gun");
						DeletePVar(playerid,"gunID");
						DeletePVar(playerOffering,"slot");
						DeletePVar(playerOffering,"matsprice");
					}
		    	}
		    	else SendClientMessage(playerid, COLOR_GREY, "You're too far away from the person offering, or either of you are in a vehicle.");
		    }
	    	else SendClientMessage(playerid, COLOR_GREY, "Nobody offered you a weapon.");
		}
Reply


Messages In This Thread
[CMD] Sellgun problem - by Maheegan - 05.02.2016, 17:43
Re: [CMD] Sellgun problem - by Cypress - 05.02.2016, 18:16

Forum Jump:


Users browsing this thread: 1 Guest(s)