error, weapons
#1

uhmm im just curious im a newbie scripter but i wanna try this command, when you type /weapon you will get a gun which cost $5000

here it is:
Код:
	if (strcmp("/weapons", cmdtext, true, 10) == 0)
	{
		GivePlayerWeapon(playerid, 26, 500);
                GetPlayerMoney(playerid, 5000);
		return 1;
	}
but i cant get it right,.. anyone
Reply
#2

pawn Код:
if (strcmp("/weapons", cmdtext, true, 10) == 0)
{
    GivePlayerWeapon(playerid, 26, 500);
        GivePlayerMoney(playerid,-5000);
        return 1;
}
Reply
#3

how about ill create a player dialog with many weapons? then when they bought it already -5000 again, anyway thanks
Reply
#4

pawn Код:
if (strcmp("/weapons", cmdtext, true, 10) == 0)
{
    if(GetPlayerMoney(playerid) >= 5000)
    {
    GivePlayerWeapon(playerid, 26, 500);
        GivePlayerMoney(playerid,-5000);
    }
    else
         SendClientMessage(playerid, 0xAFAFAFAA, "You dont have the amount to buy");

        return 1;
}
Here is more Advanced this will check if Your money is More then 5000 If it isent it will return a Error
Reply
#5

I suggest you to use Dialogs
pawn Код:
if (strcmp(cmdtext, "/buyweapons", true) == 0) {
        ShowPlayerDialog(playerid, 1, DIALOG_STYLE_LIST, "{00FFFF}List of Weapons", "Deagle (500) ($50000)\nMp5 (500) ($50000)\nM4 (500) ($50000) \nAK-47 (500) ($50000)\nCombat Shotgun (200) ($50000)", "Purchase", "Cancel");
        return 1;
    }
Then on Respond
pawn Код:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
    if(response) {                                // They pressed the first button.
        switch(dialogid == 1) {                   // If you only have one dialog, then this isn't required, but it's neater for when you implement more dialogs.
            case 1:                               // Our dialog!
            {
                switch(listitem) {                // Checking which listitem was selected
                    case 0:                       // The first item listed
                    {
                        if(GetPlayerMoney(playerid) < 1) return SendClientMessage(playerid, 0xFFFFFF, "You don't have enough cash.");
                        GivePlayerMoney(playerid, -50000);
                        GivePlayerWeapon(playerid, 24, 500);

                    }
                    case 1:                       // The second item listed
                    {
                        if(GetPlayerMoney(playerid) < 1) return SendClientMessage(playerid, 0xFFFFFF, "You don't have enough cash.");
                        GivePlayerMoney(playerid, -50000);
                        GivePlayerWeapon(playerid, 29, 500);
                    }
                    case 2:                       // The third item listed
                    {
                        if(GetPlayerMoney(playerid) < 1) return SendClientMessage(playerid, 0xFFFFFF, "You don't have enough cash.");
                        GivePlayerMoney(playerid, -50000);
                        GivePlayerWeapon(playerid, 31, 500);
                    }
                    case 3:
                    {
                        if(GetPlayerMoney(playerid) < 1) return SendClientMessage(playerid, 0xFFFFFF, "You don't have enough cash.");
                        GivePlayerMoney(playerid, -50000);
                        GivePlayerWeapon(playerid, 30, 500);
                    }
                    case 4:
                    {
                        if(GetPlayerMoney(playerid) < 1) return SendClientMessage(playerid, 0xFFFFFF, "You don't have enough cash.");
                        GivePlayerMoney(playerid, -50000);
                        GivePlayerWeapon(playerid, 27, 200);
                    }
                }
            }
        }
    }
//More
If you want to add more continuou with
pawn Код:
case 5:
Reply
#6

thank you very very much!
Reply
#7

No Problem
Reply
#8

how about ill create a /help dialog? im having problem.

this is on the onplayercommand
Код:
    if (strcmp(cmdtext, "/help", true) == 0) {
        ShowPlayerDialog(playerid, 2, DIALOG_STYLE_LIST, "{00FFFF}List Of Commands", "/heal/n/armor/n/buyweapons", "Close");
        return 1;
	}
i dunno what to put on this onplayerdialog something. im trying to put /heal /armor /buyweapons..
Код:
    if(response) {
        switch(dialogid ==2)
            case 1:
            {
                switch(listitem) {
					case 0:
	 				{
	 				    if(
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)