CMD:selldrugs(playerid, params[])
{
new pName[24], string[200];
if(sscanf(params, "ui", iId, iAmount))
return SendClientMessage(playerid, DEEPPINK, "USAGE: /selldrugs <id> <amount>");
if(!IsPlayerConnected(iId))
return SendClientMessage(playerid, DEEPPINK, "ERROR: Player is not connected");
if(PlayerInfo[playerid][pDrugs] = 0)
return SendClientMessage(playerid, DEEPPINK, "ERROR: You don't have any drugs to sell");
if(playerid == iId)
return SendClientMessage(playerid, DEEPPINK, "ERROR: You can't sell drugs to yourself");
if (GetPlayerMoney(playerid) < iAmount)
return SendClientMessage(playerid, DEEPPINK, "ERROR: Insufficent funds");
{
GetPlayerName(playerid, pName, sizeof pName);
format(string, sizeof(string), ""COL_RED"\t\tDrug Sellers\n\n"COL_RED"%s "COL_WHITE"wants to sell you a drug for "COL_RED"%d "COL_WHITE"amount\nDo you want to you buy one?", pName, iAmount);
ShowPlayerDialog(iId, DIALOG_SELLDRUGS, DIALOG_STYLE_MSGBOX, ""COL_WHITE"Drug Sellers", string, "Yes", "No");
}
return 1;
}
case DIALOG_SELLDRUGS:
{
if(!response)
{
return 1;
}
if(response)
{
PlayerInfo[playerid][pDrugs]--;
PlayerInfo[iId][pDrugs]++;
GivePlayerMoney(playerid, iAmount);
GivePlayerMoney(iId, - iAmount);
}
return 1;
}
CMD:selldrugs(playerid, params[])
{
new pName[24], string[200];
if(sscanf(params, "ui", iId, iAmount))
return SendClientMessage(playerid, DEEPPINK, "USAGE: /selldrugs <id> <amount>");
if(!IsPlayerConnected(iId))
return SendClientMessage(playerid, DEEPPINK, "ERROR: Player is not connected");
if(PlayerInfo[playerid][pDrugs] = 0)
return SendClientMessage(playerid, DEEPPINK, "ERROR: You don't have any drugs to sell");
if(playerid == iId)
return SendClientMessage(playerid, DEEPPINK, "ERROR: You can't sell drugs to yourself");
if (GetPlayerMoney(playerid) < iAmount)
return SendClientMessage(playerid, DEEPPINK, "ERROR: Insufficent funds");
{
GetPlayerName(playerid, pName, sizeof pName);
format(string, sizeof(string), ""COL_RED"\t\tDrug Sellers\n\n"COL_RED"%s "COL_WHITE"wants to sell you a drug for "COL_RED"%d "COL_WHITE"amount\nDo you want to you buy one?", pName, iAmount);
SetPVarInt(playerid, "iAmount", iAmount); //This basically saves a player variable onto that playerid with the names iAmount and iId
SetPVarInt(playerid, "iId", iId); // The middle option doesnt have to be the same as the variable you are storing
ShowPlayerDialog(iId, DIALOG_SELLDRUGS, DIALOG_STYLE_MSGBOX, ""COL_WHITE"Drug Sellers", string, "Yes", "No");
}
return 1;
}
//Now onto OnPlayerDialogResponse.
case DIALOG_SELLDRUGS:
{
if(!response)
{
return 1;
}
if(response)
{
new iAmount, iId;
iAmount = GetPVarInt(playerid, "iAmount");
iId = GetPVarInt(playerid, "iId"); //Now we are simply getting the player variables which we stored in the command.
DeletePVar(playerid, "iAmount");
DeletePVar(playerid, "iId"); //Just deleting the player variables since we are no longer using them.
PlayerInfo[playerid][pDrugs]--;
PlayerInfo[iId][pDrugs]++;
GivePlayerMoney(playerid, iAmount);
GivePlayerMoney(iId, - iAmount);
}
return 1;
}
case DIALOG_SELLDRUGS:
{
if(!response)
{
return 1;
}
if(response)
{
new Amount, pID;
Amount = GetPVarInt(playerid, "iAmount");
pID = GetPVarInt(playerid, "iId"); //Now we are simply getting the player variables which we stored in the command.
DeletePVar(playerid, "iAmount");
DeletePVar(playerid, "iId"); //Just deleting the player variables since we are no longer using them.
PlayerInfo[playerid][pDrugs]--;
PlayerInfo[pID][pDrugs]++;
GivePlayerMoney(playerid, Amount);
GivePlayerMoney(pID, - Amount);
}
return 1;
}
Originally Posted by SampWiki;
You MUST return 0 here! Just like OnPlayerCommandText.
|