30.04.2013, 20:34
Hello everyone im getting trouble with /selldrug commands, can someone help me please? IT consists that u do /selldrugs <id> <amount> and when player clicks on yes on the dialog he gets 1 drug and gets - amount of money, and the seller gets one less drug and more money.. here is my script.. i have already defined all ...
OnDialogResponse
please help me , reegards, MiGu3X
pawn Код:
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;
}
pawn Код:
case DIALOG_SELLDRUGS:
{
if(!response)
{
return 1;
}
if(response)
{
PlayerInfo[playerid][pDrugs]--;
PlayerInfo[iId][pDrugs]++;
GivePlayerMoney(playerid, iAmount);
GivePlayerMoney(iId, - iAmount);
}
return 1;
}