SA-MP Forums Archive
Little help please - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Little help please (/showthread.php?tid=550620)



Little help please - LeXuZ - 13.12.2014

Hello, i've been trying to make a deathmatch, I am having trouble with a lot of things on it, like if it's checking if another death match is on and sending the player to the death match..

First problem:
pawn Код:
public OnPlayerPickUpPickup(playerid, pickupid)
{
    if(pickupid == DeathMatch)
    {
    Deathmatchon = true;
    SendClientMessage(playerid, -1, "There is already a death match on!");
    {
    Deathmatchon = false;
    ShowPlayerDialog(playerid, Deathmatch, DIALOG_STYLE_LIST, "DeathMatch list", "LS carpark DM\nLV warehouse DM\nSF tennis courts" , "Yes", "No"); // Add more if you want!
    }
    }
    return 1;
}
This should stop the player from opening the dialog if there is another death match on but it doesn't, and i am getting an error on this line
pawn Код:
Deathmatchon = false;
with the error of
Код:
C:\Users\BLACK\Desktop\Test\filterscripts\DeathMatch.pwn(75) : error 033: array must be indexed (variable "Deathmatchon")
I've tried setting the false to 0 instead and that didn't work.
Код:
new Deathmatchon[MAX_PLAYERS];
new DMPlayer[MAX_PLAYERS];
this is how it's defined as.

second problem:
After the player has clicked on the yes button to allow them in the deathmatch it does nothing, just closes the dialog.
pawn Код:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
    if(dialogid == Deathmatch)
    {
        if(!response) return 0;
        {
            switch(listitem)
            {
                    case 0:
                    {
                        ShowPlayerDialog(playerid, LSDM, DIALOG_STYLE_MSGBOX, "LS carpark DM", "You have chosen LS carpark DM, do you want to start the death match?", "Yes", "No");
                    }
                    case 1:
                    {
                        ShowPlayerDialog(playerid, LVDM, DIALOG_STYLE_MSGBOX, "LV warehouse DM", "You have chosen LV warehouse DM, do you want to start the death match?", "Yes", "No");
                    }
                    case 2:
                    {
                        ShowPlayerDialog(playerid, SFDM, DIALOG_STYLE_MSGBOX, "SF tennis courts DM", "You have chosen SF tennis courts DM, do you want to start the death match?", "Yes", "No");
                    }
            }
        }
    }
    if(dialogid == LSDM)
    {
        if(!response) return 0;
        {
            switch(listitem)
            {
                case 0:
                {
                DMPlayer = true;
                Deathmatchon = true;
                SetPlayerPos(playerid, 2798.2031,-1465.9199,24.1875);
                GivePlayerWeapon(playerid, 28, 999999);
                SetPlayerHealth(playerid, 100);
                return 1;
                }

        }
            if(dialogid == LVDM)
        {
        if(!response) return 0;
        {
            switch(listitem)
            {
                case 0:
                {
                DMPlayer = true;
                Deathmatchon = true;
                SetPlayerPos(playerid, 1061.1685,2080.8584,10.8203);
                GivePlayerWeapon(playerid, 24, 999999);
                SetPlayerHealth(playerid, 100);
                return 1;
                }

    }
            if(dialogid == LVDM)
    {
        if(!response) return 0;
        {
            switch(listitem)
            {
                case 0:
                {
                DMPlayer = true;
                Deathmatchon = true;
                SetPlayerPos(playerid, -2787.9775,-268.9075,7.1875);
                GivePlayerWeapon(playerid, 26, 999999);
                SetPlayerHealth(playerid, 100);
                return 1;
                }
                }
            }
        }
    }
   }
  }
 }
    return 1;
}
I can't find out what i'm doing wrong, I have been looking for the errors for over an hour and couldn't fix them.
If you're able to help me that would be great!
Thank you!


Re: Little help please - Mic_H - 14.12.2014

Array must be indexed; error comes up when you use
PHP код:
Deathmatchon false;
instead of
Deathmatchon
[playerid/i] = false
For the OnPlayerDialogResponse:
One of your OnPlayerDialogResponse scripts might have "return 1;" mentioned at the bottom.. Change it to "return 0;" and we are cool..

Rest of the questions, I didnt understand


Re: Little help please - LeXuZ - 14.12.2014

Still don't know how it fix it, what you said did nothing, thanks for replying anyway, if anyone else knows how to fix it please reply, thank you!


Re: Little help please - Ryz - 14.12.2014

Deathmatchon[playerid] = false;

do it

EDIT:

sorry

change
pawn Код:
new Deathmatchon[MAX_PLAYERS];
to
pawn Код:
new Deathmatchon;
and correct

pawn Код:
public OnPlayerPickUpPickup(playerid, pickupid)
{
    if(pickupid == DeathMatch)
    {
       if (Deathmatchon == true)
       {
           SendClientMessage(playerid, -1, "There is already a death match on!");
       }
       else if (Deathmatchon == false)
       {
           ShowPlayerDialog(playerid, Deathmatch, DIALOG_STYLE_LIST, "DeathMatch list", "LS carpark DM\nLV warehouse DM\nSF tennis courts" , "Yes", "No"); // Add more if you want!
       }
    }
    return 1;
}



Re: Little help please - SickAttack - 14.12.2014

Quote:
Originally Posted by Ryz
Посмотреть сообщение
Deathmatchon[playerid] = false;

do it

EDIT:

sorry

change
pawn Код:
new Deathmatchon[MAX_PLAYERS];
to
pawn Код:
new Deathmatchon;
and correct

pawn Код:
public OnPlayerPickUpPickup(playerid, pickupid)
{
    if(pickupid == DeathMatch)
    {
       if (Deathmatchon == true)
       {
           SendClientMessage(playerid, -1, "There is already a death match on!");
       }
       else if (Deathmatchon == false)
       {
           ShowPlayerDialog(playerid, Deathmatch, DIALOG_STYLE_LIST, "DeathMatch list", "LS carpark DM\nLV warehouse DM\nSF tennis courts" , "Yes", "No"); // Add more if you want!
       }
    }
    return 1;
}
You're wrong, if you're going to hold false and true in a variable use booleans.


Edit it to your needs. It won't work as how it is. Edit the pickup's coordinates.
pawn Код:
#include <streamer>

new bool:gDeathMatchState = false,
gDeathMatch;

#define DIALOG_DEATHMATCH 0
#define DIALOG_LSDM 1
#define DIALOG_LVDM 2
#define DIALOG_SFDM 3

public OnGameModeInit()
{
    gDeathMatch = CreateDynamicPickup(19193, 1, 0.0, 0.0, 0.0, -1, -1, -1, 100.0);
    return 1;
}

public OnPlayerPickUpDynamicPickup(playerid, pickupid)
{
    if(pickupid == gDeathMatch)
    {
        if(gDeathMatchState == true) return SendClientMessage(playerid, -1, "There is already a death match on!");
        else if(gDeathMatchState == false) return ShowPlayerDialog(playerid, DIALOG_DEATHMATCH, DIALOG_STYLE_LIST, "DeathMatch list", "LS carpark DM\nLV warehouse DM\nSF tennis courts" , "Yes", "No");
    }
    return 1;
}

public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
    siwtch(dialogid)
    {
        case DIALOG_DEATHMATCH:
        {
            if(!response) return 1;
            else if(response)
            {
                switch(listitem)
                {
                    case 0: ShowPlayerDialog(playerid, DIALOG_LSDM, DIALOG_STYLE_MSGBOX, "LS carpark DM", "You have chosen LS carpark DM, do you want to start the death match?", "Yes", "No");
                    case 1: ShowPlayerDialog(playerid, DIALOG_LVDM, DIALOG_STYLE_MSGBOX, "LV warehouse DM", "You have chosen LV warehouse DM, do you want to start the death match?", "Yes", "No");
                    case 2: ShowPlayerDialog(playerid, DIALOG_SFDM, DIALOG_STYLE_MSGBOX, "SF tennis courts DM", "You have chosen SF tennis courts DM, do you want to start the death match?", "Yes", "No");
                }
            }
        }
        case DIALOG_LSDM:
        {
            if(!response) return 1;
            else if(response)
            {
                gDeathMatchState = true;
                SetPlayerPos(playerid, 2798.2031,-1465.9199,24.1875);
                GivePlayerWeapon(playerid, 28, 999999);
                SetPlayerHealth(playerid, 100);
            }
        }
        case DIALOG_LVDM:
        {
            if(!response) return 1;
            else if(response)
            {
                gDeathMatchState = true;
                SetPlayerPos(playerid, 1061.1685,2080.8584,10.8203);
                GivePlayerWeapon(playerid, 24, 999999);
                SetPlayerHealth(playerid, 100);
            }
        }
        case DIALOG_SFDM:
        {
            if(!response) return 1;
            else if(response)
            {
                gDeathMatchState = true;
                SetPlayerPos(playerid, -2787.9775,-268.9075,7.1875);
                GivePlayerWeapon(playerid, 26, 999999);
                SetPlayerHealth(playerid, 100);
            }
        }
    }
    return 1;
}
Add me on Skype if you would like further assistance. Skype: sickattack.


Re: Little help please - Ryz - 14.12.2014

who cares about bool, i just given him way to do that! not to script for him