[HELP] /selldrugs CMD :(
#4

Alrighty, this is what you need to do :

PHP код:
CMD:selldrugs(playeridparams[])
{
    new 
pName[24], string[200];
    
    if(
sscanf(params"ui"iIdiAmount))
        return 
SendClientMessage(playeridDEEPPINK"USAGE: /selldrugs <id> <amount>");
        
    if(!
IsPlayerConnected(iId))
        return 
SendClientMessage(playeridDEEPPINK"ERROR: Player is not connected");
        
    if(
PlayerInfo[playerid][pDrugs] = 0)
        return 
SendClientMessage(playeridDEEPPINK"ERROR: You don't have any drugs to sell");
    if(
playerid == iId)
        return 
SendClientMessage(playeridDEEPPINK"ERROR: You can't sell drugs to yourself");
        
    if (
GetPlayerMoney(playerid) < iAmount)
        return 
SendClientMessage(playeridDEEPPINK"ERROR: Insufficent funds");
        
    {
        
GetPlayerName(playeridpNamesizeof pName);
        
format(stringsizeof(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?"pNameiAmount);
        
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(iIdDIALOG_SELLDRUGSDIALOG_STYLE_MSGBOX""COL_WHITE"Drug Sellers"string"Yes""No");
    }
    return 
1;
}
//Now onto OnPlayerDialogResponse. 
case DIALOG_SELLDRUGS:
        {
            if(!
response)
            {
                return 
1;
            }
            if(
response)
            {
                new 
iAmountiId
                
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(playeridiAmount);
                
GivePlayerMoney(iId, - iAmount);
            }
            return 
1;
        } 
It's very easy once you understand how it works.
Reply


Messages In This Thread
[HELP] /selldrugs CMD :( - by MiGu3X - 30.04.2013, 20:34
Re: [HELP] /selldrugs CMD :( - by Chenko - 01.05.2013, 00:07
Re: [HELP] /selldrugs CMD :( - by MiGu3X - 01.05.2013, 00:11
Re: [HELP] /selldrugs CMD :( - by Chenko - 01.05.2013, 00:24
Re: [HELP] /selldrugs CMD :( - by MiGu3X - 01.05.2013, 00:25
Re: [HELP] /selldrugs CMD :( - by Chenko - 01.05.2013, 00:30
Respuesta: [HELP] /selldrugs CMD :( - by MiGu3X - 01.05.2013, 04:32
Re: [HELP] /selldrugs CMD :( - by MiGu3X - 02.05.2013, 13:08
Re: [HELP] /selldrugs CMD :( - by MiGu3X - 10.05.2013, 00:50
Re: [HELP] /selldrugs CMD :( - by horsemeat - 10.05.2013, 02:25

Forum Jump:


Users browsing this thread: 1 Guest(s)