22.01.2019, 22:56
I have a /frespawn system, that prompts a dialog for any administrator, for him to select that faction. After he chooses the faction, he's listed with either respawning every vehicle, or just a single ID.
My idea is, the "FactionSelected = listitem;" doesn't work. It doesn't understand the FactionID of the faction chosen. It doesn't understand what listitem is... Why is this? Can it be used somehow else? Enums are used for the factions, so if you make something up as a solution, I'll try to translate it to mine. The codes are in separate files.
Below is the code:
My idea is, the "FactionSelected = listitem;" doesn't work. It doesn't understand the FactionID of the faction chosen. It doesn't understand what listitem is... Why is this? Can it be used somehow else? Enums are used for the factions, so if you make something up as a solution, I'll try to translate it to mine. The codes are in separate files.
Below is the code:
pawn Code:
YCMD:frespawn(playerid, params[]) {
new vehicleid, text[12];
if(PlayerInfo[playerid][pAdminlevel] > 0)
{
if(GetPVarInt(playerid, "StaffLogin") == 0) return SendClientMessage(playerid, COLOR_LIGHTRED, "You must be logged into the staff panel to access administration commands. (/stafflogin)");
{
format(gVar3000, sizeof(gVar3000), "%s", EOS);
for(new i=0; i<sizeof(FactionInfo); i++) {
if(!isnull(FactionInfo[i][fName])) {
if(isnull(gVar3000)) {
format(gVar3000, sizeof(gVar3000), "%s", FactionInfo[i][fName]);
} else {
format(gVar3000, sizeof(gVar3000), "%s\n%s", gVar3000, FactionInfo[i][fName]);
}
}
}
format(gVar3000, sizeof(gVar3000), "%s", gVar3000);
ShowPlayerDialogEx(playerid, DIALOG_FRESPAWN, DIALOG_STYLE_LIST, "{FF9900}Faction Respawn", gVar3000, "Select", "Cancel");
format(gVar3000, sizeof(gVar3000), "%s", EOS);
}
}
else return SendClientMessage(playerid, COLOR_LIGHTRED, "You are not authorized to use this command.");
return 1;
}
pawn Code:
switch(dialogid)
{
case DIALOG_FRESPAWN:
{
if(response)
{
FactionSelected = listitem;
print("%s %d", FactionSelected, FactionSelected);
{
ShowPlayerDialogEx(playerid, DIALOG_FRESPAWN_SELECT, DIALOG_STYLE_LIST, "{FF9900}Faction Respawn", "Frespawn all\nRespawn ID", "Select", "Cancel");
}
}
}
case DIALOG_FRESPAWN_SELECT:
{
if(response)
{
switch(listitem)
{
case 0:
{
for(new v = GetVehiclePoolSize(); v > 0; v--)
{
if(VehicleInfo[v][vFaction] != 0 && FactionSelected)
{
SetVehicleToRespawn(v);
}
}
}
case 1:
{
ShowPlayerDialogEx(playerid, DIALOG_FRESPAWN_SELECT_ID, DIALOG_STYLE_INPUT, "{FF9900}Faction Respawn", "Enter a vehicle ID below to respawn it.", "Select", "Cancel");
}
}
}
}
case DIALOG_FRESPAWN_SELECT_ID:
{
if(response)
{
new inputtextint = strval(inputtext);
if(VehicleInfo[FactionSelected][vFaction] == inputtextint)
{
SetVehicleToRespawn(inputtextint);
}
}
}