Loop + Dialog question.
#1

Hi,

I got a small question, when I do /factions for example, it's displaying the factions.

Let's say:

Faction 1: LSPD
Faction 2: Hitman
Faction 3: FBI

If I remove faction 2, when I use /factions and press at FBI, I'll be fucked since he's at the ID of the hitman, so he displays an empty group.

Anyone got a fix for this?
Reply
#2

Got any code for this?
Reply
#3

I suppose it is DIALO_LIST so case 0: will be that of LSPD, case 1: will be Hitman and case 2: will be FBI. So under OnPlayerDialogResponse you will have to change them as well.
Reply
#4

Imagine; you got a dynamic faction system, you will create 3 factions:

1: LSPD
2: LSFMD
3: Hitman

Then you decide to remove the LSFMD, this will make:

1: LSPD
2: None
3: HItman

It'll display as this on /factions:

1: LSPD
3: Hitman

The LSFMD would be left out since it's removed, but if I press on hitman now it gives infromation about faction 2 which was LSFMD
Reply
#5

Show your /factions command, and your dialog response.
Reply
#6

Код:
CMD:editfaction(playerid, params[]) // Edits the faction through a dialog
{
    if(CharacterData[playerid][pAdmin] >= 5)
	{
		new totalfac = 0, largestring[504];
	    for(new i = 1; i < MAX_FACTIONS; i++)
		{
			if(FactionData[i][fac_Taken] == 1)
	    	{
	    	    format(largestring, sizeof(largestring), "%s ID %d) %s\n", largestring, i, FactionData[i][fac_Name]);
	    	    totalfac ++;
	    	}
	    }
	    if(totalfac == 0) return ErrorMessage(playerid, "No factions have been created yet");
	    ShowPlayerDialog(playerid, DIALOG_EDITFACTION_ID, DIALOG_STYLE_LIST, "Select the faction which you would like to edit", largestring, "Select", "Cancel");
	}
	else
	{
	    return ErrorMessage(playerid, "You are not authorized to use that command!");
	}
	return 1;
}
Код:
case DIALOG_EDITFACTION_ID:
		{
		    new title[64], availablefacs[MAX_FACTIONS+1], factionID;
		    if(!response) return 1;
	        if(response)
	        {
			    for(new i = 1; i < MAX_FACTIONS; i++)
				{
					if(FactionData[i][fac_Taken] == 1)
			    	{
                        availablefacs[i] = i;
			    	}
			    }
			    for(new i = 1; i < MAX_FACTIONS; i++)
				{
					if(FactionData[i][fac_Taken] == 1)
			    	{
						i = factionID;
			    	}
			    }
			    for(new i = AtFaction[playerid]; i < sizeof(availablefacs[i]); i++)
			    {
			    
			    
			    }
			    
	            format(title, sizeof(title), "Editting faction: %s(ID: %d)", FactionData[factionID][fac_Name], factionID);
	            ShowPlayerDialog(playerid, DIALOG_EDITFACTION, DIALOG_STYLE_LIST, title, "Change Name\nChange Rank Names\nFaction Type\nFaction Color\nDelete Faction", "Select", "Cancel");
	        }
		}
Reply
#7

Bump, and I got another question I added this hitman system on OnPlayerDeath:

Код:
printf("OnPlayerDeath: %d | %d | %d | %d", playerid, killerid, reason, AcceptedHit[playerid]);
// is called
Код:
if (AcceptedHit[playerid] == killerid && killerid != INVALID_PLAYER_ID && AcceptedHit[playerid] != 999)
	{
	    printf("OnPlayerDeath: %d | %d | %d | %d", playerid, killerid, reason, AcceptedHit[playerid]); // Not getting called
	    new string[128];
	    for(new i = 1; i < MAX_FACTIONS; i++)
		{
			if(FactionData[i][fac_Taken] == 1 && FactionData[i][fac_Type] == FAC_TYPE_HITMEN)
	    	{
	    	    format(string, sizeof(string),"Hitman %s has failed the contract on %s and lost $%d.", PlayerRPName(playerid), PlayerRPName(killerid), CharacterData[killerid][pBounty]/2);
				SendFactionMessage(i, YELLOW, string);
	    	}
	    }
		format(string, sizeof(string),"You have killed a hitman and gained $%d, the contract on your head has been removed.", CharacterData[killerid][pBounty]/2);
		SendClientMessage(killerid, YELLOW, string);
	    CharacterData[playerid][pFailedHits] ++;
	    PlayerJustDied[playerid] = 1;
	    GiveMoney(playerid, -CharacterData[killerid][pBounty]/2);
	    GiveMoney(killerid, CharacterData[killerid][pBounty]/2);
	    AcceptedHit[playerid] = 999;
	    CharacterData[killerid][pBounty] = 0;
	    printf("OnPlayerDeath: %d | %d | %d | %d", playerid, killerid, reason, AcceptedHit[playerid]);
	    return 1;
	}
The code here above is blocking the rest from OnPlayerDeath, it blocks it somehow even though it shouldn't be even do something, debug:

Код:
 OnPlayerDeath: 0 | 65535 | 255 | 999
Reply
#8

On dialog response, just loop again and use the same if statements used in the command commands or function. IMPORTANT: add a counter for the loop then match them with the listitem.

Ror example:

pawn Код:
COMMAND:mycars(playerid)
{
    new MainStr[ 500 ], iFormat[ 128 ];
    VehicleLoop(v)
    {
        if(VehicleInfo[v][vActive] != 1) continue;
        if(!strcmp(VehicleInfo[v][owner], PlayerName(playerid), false))
        {
            format(iFormat, sizeof, "ID: [%d]\n", v);
            strcat(MainStr, iFormat);
        }
    }
    ShowPlayerDialog(playerid, MY_CARS, DIALOG_STYLE_LIST, "Vehicles owned by you!", MainStr, "Select", "");
    return 1;
}
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
    if(listitem == MY_CARS)
    {
        if(response)
        {
            new count, finalid;
            VehicleLoop(v)
            {
                if(VehicleInfo[v][vActive] != 1) continue;
                if(!strcmp(VehicleInfo[v][owner], PlayerName(playerid), false))
                {
                    if(count == listitem)
                    {
                        finalid = v;
                    }
                    count++;
                }
            }
            format(iFormat, sizeof(iFormat), "Congratulations my prince, you own ID: %d", finalid);
            ShowPlayerDialog(playerid, MY_CARS, DIALOG_STYLE_MSGBOX, "Wow, mr big time.", iFormat, "Select", "");  
        }
    }
}
Reply
#9

Fixed the faction issue, still need an answer for the OnPlayerDeath
Reply


Forum Jump:


Users browsing this thread: