SA-MP Forums Archive
Help with /sellgun cmd - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Help with /sellgun cmd (/showthread.php?tid=489904)



Help with /sellgun cmd - AlbanianBadBoy - 24.01.2014

I need help actually if u can, I can fix it out maybe vut in days so I thou' someons can help , even if none can help me anyways thanks, I actually got the sellgun cmd but I wan to add a sniper but with restrictons I got factions and nyo script so I wabt to male able that the gun can be sold oly to a t1 or t0 .. So not all will be,able to get a sniper thanks.


Re: Help with /sellgun cmd - BizzyD - 24.01.2014

Hmm, this will be easy to do.
If we had your damn code...


Re: Help with /sellgun cmd - [TMS]Legena - 24.01.2014

Quote:
Originally Posted by [SWE]Alexzz
Посмотреть сообщение
Hmm, this will be easy to do.
If we had your damn code...
Agree with you Without your code we cant make it compatible.


Re: Help with /sellgun cmd - AlbanianBadBoy - 24.01.2014

Код:
}
COMMAND:gundealer(playerid, params[])
{
	if(IsPlayerFED(playerid))
		return SendClientError(playerid, CANT_USE_CMD);
    if(!IsPlayerInSphere(playerid,2201.1729,-1970.2307,13.7841,5))
		return SendClientError(playerid, "You are not at the right location!");
    if(strcmp(PlayerInfo[playerid][job],"None",true))
        return SendClientMessage(playerid,COLOR_RED,"[JOB] You already have a job - Use \"/quitjob\" to leave your current one!");

	myStrcpy(PlayerInfo[playerid][job],"GunDealer");
	ShowInfoBox(playerid, "GunDealer", "congratulations, you are now a ~r~gundealer~w~! Use /jobhelp to see your new commands. Check your radar for the place to buy guns!");
	SetPlayerCheckpoint(playerid, -33.6417,-1122.1495,1.0970, 3.0);
	format(iStr, sizeof(iStr), "6[JOB] %s is now a GunDealer!", PlayerName(playerid));
	return 1;
}
enum _wdata
{
	wname[ 12 ],
	wID,
	wAmmo,
	wSellables,
}
new weapon_arr[][_wdata] = {
	// Weapon ,  ID, Ammo, Materials
	{ "Katana",   8, 1  , 1},
	{ "Flowers",  14,1  , 1},
	{ "Molotov",  18,1  , 12},
	{ "Deagle",	  24,75 , 1},
	{ "MP5",	  29,150, 1},
	{ "Shotgun",  25,75 , 2},
	{ "AK47",	  30,150, 2},
	{ "M4",		  31,150, 2},
	{ "Rifle",	  33,75,  2}
};
COMMAND:sellgun(playerid, params[])
{
	if(strcmp(PlayerInfo[playerid][job],"GunDealer", true)) return SendClientError(playerid, CANT_USE_CMD);
	new iPlayer, iWeapon[ 128 ];
	if( sscanf ( params, "us", iPlayer, iWeapon))
	{
		SCP(playerid, "[PlayerID/PartOfName] [weapon]");
		new bStr[ 256 ];
		format(bStr, sizeof(bStr), "Available weapons: ");
		for(new q; q < sizeof(weapon_arr); q++)
		{
			new tmp[ 20 ];
			format(tmp, sizeof(tmp), " %s (%d ammo),", weapon_arr[q][wname], weapon_arr[q][wAmmo]);
			strcat(bStr, tmp);
		}
		strdel(bStr,strlen(bStr)-1, strlen(bStr));
		SendMessageToPlayer(playerid, COLOR_ADMIN_PM, bStr);
		return 1;
	}
	if(!IsPlayerConnected(iPlayer)) return SendClientError(playerid, PLAYER_NOT_FOUND);
	//if(iPlayer == playerid) return SendClientError(playerid, "You cannot sell any guns to yourself!");
	if(GetDistanceBetweenPlayers(playerid, iPlayer) > 3) return SendClientError(playerid, "He is too far away!");
	new dSELECT = -1;
	for(new q; q < sizeof(weapon_arr); q++)
	{
		if(strfind(weapon_arr[q][wname],iWeapon, true) != -1) dSELECT = q;
	}
	if(dSELECT == -1)
	{
		new bStr[ 256 ];
		format(bStr, sizeof(bStr), "Available weapons: ");
		for(new q; q < sizeof(weapon_arr); q++)
		{
			new tmp[ 20 ];
			format(tmp, sizeof(tmp), " %s (%d ammo),", weapon_arr[q][wname], weapon_arr[q][wAmmo]);
			strcat(bStr, tmp);
		}
		strdel(bStr,strlen(bStr)-1, strlen(bStr));
		SendMessageToPlayer(playerid, COLOR_ADMIN_PM, bStr);
		return 1;
	}
	if(PlayerInfo[playerid][sguns] < weapon_arr[dSELECT][wSellables])
		return SendClientMSG(playerid, COLOR_ADMIN_PM, "[GUNDEALER]: You don't have enough sellables! You need %d sellabes.", weapon_arr[dSELECT][wSellables]);
	format(iStr, sizeof(iStr), "has sold a %s with %d ammo to %s.", weapon_arr[dSELECT][wname],weapon_arr[dSELECT][wAmmo], MaskedName(iPlayer));
	Action(playerid, iStr);
	if(dSELECT == 3) SetPVarInt(iPlayer, "Molotov", 1);
	GivePlayerWeapon(iPlayer, weapon_arr[dSELECT][wID], weapon_arr[dSELECT][wAmmo]);
	PlayerInfo[playerid][sguns] -= weapon_arr[dSELECT][wSellables];
	PlayerInfo[playerid][jobskill] += minrand(1,2);
	format(iStr, sizeof(iStr), "6[JOB] GunDealer %s has sold a %s to %s.", PlayerName(playerid), weapon_arr[dSELECT][wname], PlayerName(iPlayer));
	SendClientMSG(playerid, COLOR_LIGHTGREY, " You lost %d sellables selling this %s. You now have %d sellables left.", weapon_arr[dSELECT][wSellables], weapon_arr[dSELECT][wname], PlayerInfo[playerid][sguns]);
	return 1;
}



Re: Help with /sellgun cmd - AlbanianBadBoy - 24.01.2014

Can someone help me