ShowPlayerDialog(playerid, dialogid, style, caption[], info[], button1[], button2[])
ShowPlayerDialog(playerid, DIALOG_BASE, DIALOG_STYLE_MSGBOX, "WARNING", "Warning, your money has dropped below 100\nwould you like to take out a loan?", "yes", "no");
ShowPlayerDialog(playerid, DIALOG_BASE + 1, DIALOG_STYLE_INPUT, "Login", "Welcome back\nInsert password to login", "login", "cancel");
ShowPlayerDialog(playerid, DIALOG_BASE + 2, DIALOG_STYLE_LIST, "Destination", "LSPD\nLVPD\nSFPD\nLS Bank\nLS Airport", "warp", "cancel");
#define MAX_DIALOGS (15)
#define DIALOG_BASE (324)
enum DialogInfo
{
DTaken,
DStyle,
DCap[64], //I have never used an array(string) in an enum like this before, untested
DInfo[512], //if you don't need it this big make it smaller.
DBut1[24],
DBut2[24]
}
new Dialogs[MAX_DIALOGS][DialogInfo];
//handleid is NOT dialog id, multiple dialogs with the same text can be shown with different id's
CreateDialog(style, caption[], info[], button1[], button2[]) //returns handleid
{
new handleid = 0;
//Tempted to use foreach here, not going to, for portability.
for ( ; handleid < MAX_DIALOGS; handleid++)
{
if (Dialogs[handleid][DTaken] == 0) break;
}
Dialogs[handleid][DTaken] = 1;
Dialogs[handleid][DStyle] = style;
format(Dialogs[handleid][DCap], sizeof(Dialogs[handleid][DCap]), caption);
format(Dialogs[handleid][DInfo], sizeof(Dialogs[handleid][DInfo]), info);
format(Dialogs[handleid][DBut1], sizeof(Dialogs[handleid][DBut1]), button1);
format(Dialogs[handleid][DBut2], sizeof(Dialogs[handleid][DBut2]), button2);
return handleid;
}
ShowDialog(playerid, dialogid, handleid)
{
if (Dialogs[handleid][PTaken] == 0) return 0;
return ShowPlayerDialog(playerid, dialogid, Dialogs[handleid][PStyle], Dialogs[handleid][PCap], Dialogs[handleid][PInfo], Dialogs[handleid][PBut1], Dialogs[handleid][PBut2]);
}
#define LOGINDIALOGPARAMS(%1,%2) %1, %2, DIALOG_STYLE_INPUT, "Login", "Welcome back!\nInsert password to login", "login", "cancel"
ShowPlayerDialog(LOGINDIALOGPARAMS(playerid, dialogid));
#define LOGINDIALOG(%1,%2) ShowPlayerDialog(%1, %2, DIALOG_STYLE_INPUT, "Login", "Welcome back!\nInsert password to login", "login", "cancel")
//used like this
LOGINDIALOG(playerid, dialogid);
//or
#define LOGINDIALOGPARAMS DIALOG_STYLE_INPUT, "Login", "Welcome back!\nInsert password to login", "login", "cancel"
//used like this
ShowPlayerDialog(playerid, dialogid, LOGINDIALOGPARAMS);
#define HidePlayerDialog(%1) ShowPlayerDialog(%1,-1,0,"","","","")
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
ShowPlayerDialog(playerid, DIALOG_BASE, DIALOG_STYLE_MSGBOX, "WARNING", "Warning, your money has dropped below 100\nwould you like to take out a loan?", "yes", "no");
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
if (dialogid == DIALOG_BASE)
{
if (response == 1)
{
PlayerLoan[playerid] += 500;
GivePlayerMoney(playerid, 500);
SendClientMessage(playerid, 0xFFFFFFFF, "You have taken a loan from the bank for $500");
}
else
{
SendClientMessage(playerid, 0xFFFFFFFF, "No loan has been taken.");
}
return 1;
}
return 0;
}
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[]) //the callback
if (dialogid == DIALOG_BASE) //checks if the dialogid is the one we want (DIALOG_BASE, which is the msgbox)
if (response == 1) //checks if the "Yes" button was pushed
PlayerLoan[playerid] += 500; //sets a variable to show that the player has taken a loan
GivePlayerMoney(playerid, 500); //gives the player the money
SendClientMessage(playerid, 0xFFFFFFFF, "You have taken a loan from the bank for $500"); //shows a message to the player
else // "No" button has been pushed
SendClientMessage(playerid, 0xFFFFFFFF, "No loan has been taken."); //tells the player that he chose to not take a loan
return 1; //returns 1 because we successfully handled it.
return 0; //returns 0 pass it on to other scripts to see if they know what this dialog is.
ShowPlayerDialog(playerid, DIALOG_BASE + 1, DIALOG_STYLE_INPUT, "Login", "Welcome back\nInsert password to login", "Login", "Cancel");
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[]) //the callback
{
if (dialogid == DIALOG_BASE + 1) //checking dialogid
{
if (response == 1) //making sure "Login" was pressed
{
if (!strcmp(inputtext, pPass[playerid])) //checking if it is the players password
{
LoginPlayer(playerid); //calling a function to log him in
}
else //incorrect password
{
ShowPlayerDialog(playerid, dialogid, DIALOG_STYLE_INPUT, "Invalid Password", "Invalid Password, try again", "Login", "Cancel"); //shows another dialog, with the same dialogid.
LogAttempts[playerid]++; //increments a variable to know how many time he has tried to login
if (LogAttempts[playerid] >=2) //is it greater then or equal to 2?
{
SendClientMessage(playerid, 0xFFFFFFFF, "Too many attempts, bye!"); //tells him what is about to happen
SetTimerEx("kicker", 200, 0, "i", playerid); //if you can't figure out what this is, see below
}
}
}
else //pressed "Cancel"
{
SendClientMessage(playerid, 0xFFFFFFFF, "well if you aren't going to login, LEAVE"); //some message
SendClientMessage(playerid, 0xFFFFFFFF, "okay, i will do it for you."); //another
SetTimerEx("kicker", 200, 0, "i", playerid); //a timer that allows the player to see the messages before he is kicked.
}
return 1; //returns 1, it has been handled
}
return 0;
}
ShowPlayerDialog(playerid, DIALOG_BASE + 2, DIALOG_STYLE_LIST, "Destination", "LSPD\nLVPD\nSFPD\nLS Bank\nLS Airport", "warp", "cancel");
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[]) //the callback
{
if (dialogid == DIALOG_BASE + 2) //checking dialogid
{
if (response == 1) //warp has been pressed
{
switch (listitem) //a switch, not going to explain it here
{
case 0:SetPlayerPos(playerid, ...); //if (listitem == 0) Set... hey look, I just explained it.
case 1:SetPlayerPos(playerid, ...); //if (listitem == 1) Set...
case 2:SetPlayerPos(playerid, ...);
case 3:SetPlayerPos(playerid, ...);
case 4:SetPlayerPos(playerid, ...);
}
SendClientMessage(playerid, 0xFFFFFFFF, "warped to destination"); //a message to confirm the warp
}
else //pressed cancel
{
SendClientMessage(playerid, 0xFFFFFFFF, "warping canceled"); //confirmation of declination
}
return 1; //returns 1, it has been handled
}
return 0;
}
for(new s; s < strlen(inputtext); s++)
{
if (inputtext == '%')
{
inputtext = ' ';
}
}
C:\Users\Thuron\Desktop\SAMP0.3\gamemodes\SIRRP.pwn(1161) : warning 236: unknown parameter in substitution (incorrect #define pattern) C:\Users\Thuron\Desktop\SAMP0.3\gamemodes\SIRRP.pwn(1161) : warning 236: unknown parameter in substitution (incorrect #define pattern) C:\Users\Thuron\Desktop\SAMP0.3\gamemodes\SIRRP.pwn(1161) : error 029: invalid expression, assumed zero C:\Users\Thuron\Desktop\SAMP0.3\gamemodes\SIRRP.pwn(1161) : warning 215: expression has no effect C:\Users\Thuron\Desktop\SAMP0.3\gamemodes\SIRRP.pwn(1161) : error 001: expected token: ";", but found ")" C:\Users\Thuron\Desktop\SAMP0.3\gamemodes\SIRRP.pwn(1161) : error 029: invalid expression, assumed zero C:\Users\Thuron\Desktop\SAMP0.3\gamemodes\SIRRP.pwn(1161) : fatal error 107: too many error messages on one line
Originally Posted by ArcticFox
thuron send the line where the error is
EDIT: Daren_Jacobson you forgot a ';' in the first pawn code |
#define MainMenu(%1,%2) %1, %2, DIALOG_STYLE_LIST, "Master", "Enter\nBuy Points\nInformation", "Select", "Exit"
if(!strcmp("/wmenu", cmdtext, true, 6)) { ShowPlayerDialog(MainMenu(playerid, dialogid)); return 1; }
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[]) { new PointsQuantity = strval(inputtext); new CurrMoney = GetPlayerMoney(playerid); gCheckout[playerid]= PointsQuantity*PointsCost; if(dialogid == DIALOGID) { if(response == 1) { if(listitem == 0) // DeathMatch Arena { if (2count >= 1count) { SetPlayerTeam(playerid,TEAM_1); new rand1 = random(sizeof(TEAM1Spawns)); SetPlayerPos(playerid, TEAM1Spawns[rand1][0], TEAM1Spawns[rand1][1], TEAM1Spawns[rand1][2]); SetPlayerFacingAngle(playerid,270); SetCameraBehindPlayer(playerid); DM[playerid] = 1; } else if (1count >= 2count) { SetPlayerTeam(playerid,TEAM_2); new rand2 = random(sizeof(TEAM2Spawns)); SetPlayerPos(playerid, TEAM2Spawns[rand2][0], TEAM2Spawns[rand2][1], TEAM2Spawns[rand2][2]); SetPlayerFacingAngle(playerid,270); SetCameraBehindPlayer(playerid); DM[playerid] = 1; } else if (1count == 2count) { SetPlayerTeam(playerid, RandomTeamJoin[random(sizeof(RandomTeamJoin))]); DM[playerid] = 1; } if(GetPlayerTeam(playerid) == TEAM_1) { 1count++; new rand1 = random(sizeof(TEAM1Spawns)); SetPlayerPos(playerid, TEAM1Spawns[rand1][0], TEAM1Spawns[rand1][1], TEAM1Spawns[rand1][2]); SetPlayerFacingAngle(playerid,270); SetCameraBehindPlayer(playerid); SendClientMessage(playerid,COLOR_BLUE, "You have joined the DeathMatch on Team 1!"); } else if(GetPlayerTeam(playerid) == TEAM_2) { 2count++; new rand2 = random(sizeof(TEAM2Spawns)); SetPlayerPos(playerid, TEAM2Spawns[rand2][0], TEAM2Spawns[rand2][1], TEAM2Spawns[rand2][2]); SetPlayerFacingAngle(playerid,270); SetCameraBehindPlayer(playerid); SendClientMessage(playerid,COLOR_RED, "You have joined the DeathMatch on Team 2!"); return 1; } else if(DM[playerid] == 1) { SendClientMessage(playerid,COLOR_RED, "You are already in a team!"); } return 1; } if(listitem == 1) // Points { ShowPlayerDialog(playerid, DIALOGID+1, DIALOG_STYLE_INPUT, "Points", "Points", "Select", "Back"); } if(listitem == 2) // Information { ShowPlayerDialog(playerid, DIALOGID+2, DIALOG_STYLE_MSGBOX, "DeathMatch","mytext", "Ok", "Cancel"); } } return 1; } if(dialogid == DIALOGID+1) // points { new s[128]; format(s,sizeof(s),"Points: %i\n\nCost: %i$",PointsQuantity,gCheckout[playerid]); ShowPlayerDialog(playerid, DIALOGID+3,0,"Points",s,"Buy","Back"); } else if(dialogid == DIALOGID+2) // info { return 1; } else if(dialogid == DIALOGID+3 && CurrMoney >= gCheckout[playerid]) // Buy points { new PointsStringbought[128]; format(PointsStringbought,sizeof(PointsStringbought),"You have bought %i Points for $%i",PointsQuantity,gCheckout[playerid]); GivePlayerMoney(playerid,-gCheckout[playerid]); PInfo[playerid][Points] = PInfo[playerid][Points]+PointsQuantity; ShowPlayerDialog(playerid, DIALOGID, DIALOG_STYLE_LIST, "Master", "Enter DeathMatch\nBuy Points\nInformation", "Select", "Cancel"); return 1; } else if(dialogid == DIALOGID+3 && CurrMoney <= gCheckout[playerid]) // Buy points { SendClientMessage(playerid,COLOR_BLUE,"You do not have enough money."); ShowPlayerDialog(playerid, DIALOGID, DIALOG_STYLE_LIST, "Master", "Enter DeathMatch\nBuy Points\nInformation", "Select", "Cancel"); return 1; } return 0; }