PDA

View Full Version : Weapon dealer


Cerealguy
20/10/2013, 10:06 PM
Hi friend, my problem or rather my question as I would accomplish that when user do buy a weapon you the money to which it sold

eg

I use / sellgun PLAYER

player use / viewguns, and I bought a 9mm which costs $ 500, the purchase is subtracted and gives me $ 500 for PLAYER


CMD:sellgun(playerid, params[])
{
new string[128], string2[128], targetid, pName[MAX_PLAYERS], pName2[MAX_PLAYERS];

if(sscanf(params,"u",targetid))
{
SendClientMessage(playerid,COLOR_YELLOW,"Usage:{FFFFFF} /sellgun [ID]");
return 1;
}
if(pInfo[playerid][Job] == 0 && pInfo[playerid][Job] == 1)
{
SendClientMessage(playerid,COLOR_RED,"[ERROR]{FFFFFF} You not are weapon dealer, You can't to use this command.");
return 1;
}
if(GetPlayerTeam(playerid) == TEAM_POLICE)
{
SendClientMessage(playerid,COLOR_RED,"[ERROR]{FFFFFF} Only civilian can use this command");
return 1;
}
if(playerid == targetid)
{
SendClientMessage(playerid,COLOR_RED,"[ERROR]{FFFFFF} You cannot sell gun yourself");
return 1;
}
if(!IsPlayerConnected(targetid)) return SendClientMessage(playerid, COLOR_RED, "[ERROR]{FFFFFF} Player not connected");
{
if(GetPlayerDistanceFromPlayer(playerid, targetid) <= 4)
{
GetPlayerName(playerid, pName, sizeof(pName));
GetPlayerName(targetid, pName2, sizeof(pName2));
format(string, sizeof(string), "[WEAPON DEALER]{FFFFFF} You will sent invitation to buy weapons a %s(%d)", pName2, targetid);
SendClientMessage(playerid, COLOR_ANTICHEAT, string);
format(string2, sizeof(string2), "[WEAPON DEALER]{FFFFFF} %s(%d) has sent an invitation to buy weapons, use {ff8300}/viewguns {FFFFFF}to buy", pName, playerid);
SendClientMessage(targetid, COLOR_ANTICHEAT, string);
Sellguns(targetid, 15000);
}
else
{
return SendClientMessage(playerid, COLOR_RED, "[ERROR]{FFFFFF} Player isn't close enough!");
}
}
return 1;
}

CMD:viewguns(playerid, params[])
{
new targetid;

if(sscanf(params,"u",targetid))
{
SendClientMessage(playerid,COLOR_YELLOW,"Usage:{FFFFFF} /viewguns [ID]");
return 1;
}
if(GetPlayerTeam(playerid) == TEAM_POLICE)
{
SendClientMessage(playerid,COLOR_RED,"[ERROR]{FFFFFF} Only civilian can use this command");
return 1;
}
if(Sellgun[playerid] == 0)
{
SendClientMessage(playerid,COLOR_RED,"[ERROR]{FFFFFF} You have not received any invitation to buy weapons");
return 1;
}
viewgun(playerid);
Sellgun[playerid] = 0;

return 1;
}


In OnPlayerDialogresponse

if(dialogid == WEAPON_DEALER)
{
if(response)
{
if(listitem == 0)
{
if(GetPlayerMonez(playerid) < 500)
return SendClientMessage(playerid, COLOR_RED, "You don't have enough cash!");
GivePlayerMonez(playerid, -500);
GivePlayerWeapon(playerid, 4, 1);
viewgun(playerid);
}
if(listitem == 1)
{
if(GetPlayerMonez(playerid) < 600)
return SendClientMessage(playerid, COLOR_RED, "You don't have enough cash!");
GivePlayerMonez(playerid, -600);
GivePlayerWeapon(playerid, 22, 10100);
viewgun(playerid);
}
if(listitem == 2)
{
if(GetPlayerMonez(playerid) < 700)
return SendClientMessage(playerid, COLOR_RED, "You don't have enough cash!");
GivePlayerMonez(playerid, -700);
GivePlayerWeapon(playerid, 23, 10100);
viewgun(playerid);
}
if(listitem == 3)
{
if(GetPlayerMonez(playerid) < 800)
return SendClientMessage(playerid, COLOR_RED, "You don't have enough cash!");
GivePlayerMonez(playerid, -800);
GivePlayerWeapon(playerid, 24, 10100);
viewgun(playerid);
}
if(listitem == 4)
{
if(GetPlayerMonez(playerid) < 700)
return SendClientMessage(playerid, COLOR_RED, "You don't have enough cash!");
GivePlayerMonez(playerid, -700);
GivePlayerWeapon(playerid, 28, 10100);
viewgun(playerid);
}
if(listitem == 5)
{
if(GetPlayerMonez(playerid) < 800)
return SendClientMessage(playerid, COLOR_RED, "You don't have enough cash!");
GivePlayerMonez(playerid, -800);
GivePlayerWeapon(playerid, 32, 10100);
viewgun(playerid);
}
if(listitem == 6)
{
if(GetPlayerMonez(playerid) < 850)
return SendClientMessage(playerid, COLOR_RED, "You don't have enough cash!");
GivePlayerMonez(playerid, -850);
GivePlayerWeapon(playerid, 29, 10100);
viewgun(playerid);
}
if(listitem == 7)
{
if(GetPlayerMonez(playerid) < 1000)
return SendClientMessage(playerid, COLOR_RED, "You don't have enough cash!");
GivePlayerMonez(playerid, -1000);
GivePlayerWeapon(playerid, 30, 10100);
viewgun(playerid);
}
if(listitem == 8)
{
if(GetPlayerMonez(playerid) < 1150)
return SendClientMessage(playerid, COLOR_RED, "You don't have enough cash!");
GivePlayerMonez(playerid, -1150);
GivePlayerWeapon(playerid, 31, 10100);
viewgun(playerid);
}
if(listitem == 9)
{
if(GetPlayerMonez(playerid) < 600)
return SendClientMessage(playerid, COLOR_RED, "You don't have enough cash!");
GivePlayerMonez(playerid, -600);
GivePlayerWeapon(playerid, 25, 10100);
viewgun(playerid);
}
if(listitem == 10)
{
if(GetPlayerMonez(playerid) < 900)
return SendClientMessage(playerid, COLOR_RED, "You don't have enough cash!");
GivePlayerMonez(playerid, -900);
GivePlayerWeapon(playerid, 27, 10100);
viewgun(playerid);
}
if(listitem == 11)
{
if(GetPlayerMonez(playerid) < 800)
return SendClientMessage(playerid, COLOR_RED, "You don't have enough cash!");
GivePlayerMonez(playerid, -800);
GivePlayerWeapon(playerid, 26, 10100);
viewgun(playerid);
}
if(listitem == 12)
{
if(GetPlayerMonez(playerid) < 950)
return SendClientMessage(playerid, COLOR_RED, "You don't have enough cash!");
GivePlayerMonez(playerid, -950);
GivePlayerWeapon(playerid, 33, 10100);
viewgun(playerid);
}
if(listitem == 13)
{
if(GetPlayerMonez(playerid) < 1100)
return SendClientMessage(playerid, COLOR_RED, "You don't have enough cash!");
GivePlayerMonez(playerid, -1100);
GivePlayerWeapon(playerid, 34, 10100);
viewgun(playerid);
}
}
}

STOCK

stock Sellguns(playerid, time)
{
Sellgun[playerid] = 1;
SetTimerEx("Viewguns", time, false, "i", playerid);
}

forward Viewguns(playerid);
public Viewguns(playerid)
{
Sellgun[playerid] = 0;
return 1;
}

SilentSoul
20/10/2013, 10:55 PM
What errors you got , or what is your problem ?

Cerealguy
20/10/2013, 11:51 PM
I need to buy a weapon the player will send the money to which it is selling