Deleting Character and Creating Character dialog.
#1

pawn Код:
case DIALOG_MAIN_MENU_CHARACTER_DELETE:
        {
            if(response)
            {
                if(strlen(inputtext) >= 1)
                {
                    if(CharacterExists(mysql_real_escape_string(inputtext, InsertPlayerUnderscoreString))) //2457
                    {
                        new escapedstring[50];
                        mysql_real_escape_string(InsertPlayerUnderscoreString(inputtext), escapedstring);
                        if(PlayerOwnsCharacter_Name(playerid, escapedstring)); //2461
                        {
                            new query[128];
                            format(query, sizeof(query), "DELETE FROM `Character` WHERE `cName` = '%s'", (InsertPlayerUnderscoreString(inputtext)); //(InsertPlayerUnderscoreString(inputtext) //2464
                           
                            format(query, sizeof(query), "[I:] You have successfully deleted character: %s.", inputtext);
                            SendClientMessage(playerid, COLOR_YELLOW, query);
                            ShowMenuDialog(playerid);
                        }
                        else //2470
                        {
                            ShowPlayerDialog(playerid,DIALOG_MAIN_MENU_CHARACTER_DELETE,DIALOG_STYLE_INPUT,"Master Account - Delete Character","What is the name of the character you wish to delete?\nYou will not be able to recover it after it has been deleted!\n(Firstname Lastname format)","Delete","Go Back");
                        }
                    }
                    else
                    {
                         ShowPlayerDialog(playerid,DIALOG_MAIN_MENU_CHARACTER_DELETE,DIALOG_STYLE_INPUT,"Master Account - Delete Character","What is the name of the character you wish to delete?\nYou will not be able to recover it after it has been deleted!\n(Firstname Lastname format)","Delete","Go Back");
                    }
                }
                else
                {
                     ShowPlayerDialog(playerid,DIALOG_MAIN_MENU_CHARACTER_DELETE,DIALOG_STYLE_INPUT,"Master Account - Delete Character","What is the name of the character you wish to delete?\nYou will not be able to recover it after it has been deleted!\n(Firstname Lastname format)","Delete","Go Back");
                }
            }
            else
            {
                ShowPlayerDialog(playerid, DIALOG_MAIN_MENU_OPTIONS, DIALOG_STYLE_LIST, "Main Menu - Options", "Create New Character\nDelete Character\nChange Password\nDisconnect", "Continue", "Go Back");
            }
        }
        case DIALOG_MAIN_MENU_CREATE_CHARACTER_NAME:
        {
            new firstname[MAX_PLAYER_NAME], lastname[MAX_PLAYER_NAME];
            if(response)
            {
                if(strlen(inputtext) >= 1 && strlen(inputtext) <= MAX_PLAYER_NAME)
                {
                    if(!CharacterExists(InsertPlayerUnderscoreString(inputtext)))
                    {
                        if(RPName(InsertPlayerUnderscoreString(inputtext), firstname, lastname))
                        {
                            SetPVarString(playerid,"TEMP_C_NAME",InsertPlayerUnderscoreString(sqlite_escape_string(inputtext))); //2501
                        }
                        else
                        {
                            ShowPlayerDialog(playerid,DIALOG_MAIN_MENU_CREATE_CHARACTER_NAME,DIALOG_STYLE_INPUT,"Master Account - New Character","The character name you entered is not a valid roleplay name.\n(Firstname Lastname format).","Continue","Go Back");
                        }
                    }
                    else
                    {
                        ShowPlayerDialog(playerid,DIALOG_MAIN_MENU_CREATE_CHARACTER_NAME,DIALOG_STYLE_INPUT,"Master Account - New Character","A character with that name is already registered, please choose another name.\n(Firstname Lastname format).","Continue","Go Back");
                    }
                }
                else
                {
                    ShowPlayerDialog(playerid,DIALOG_MAIN_MENU_CREATE_CHARACTER_NAME,DIALOG_STYLE_INPUT,"Master Account - New Character","What do you want your character to be called?\n(Firstname Lastname format).","Continue","Go Back");
                }
                CreateCharacter(playerid, //2517
                GetPVarStringEx(playerid, "TEMP_C_NAME"),
                CivilianSpawn[Float:CivX], //2519
                CivilianSpawn[Float:CivY],
                CivilianSpawn[Float:CivZ],
                CivilianSpawn[World],
                CivilianSpawn[Interior],
                CivilianSpawn[Angle],
                Settings[sDEFAULT_P_CASH],
                Settings[sDEFAULT_P_BANK],
                Settings[sDEFAULT_P_SKIN]);
                DeletePVar(playerid, "TEMP_C_NAME");
                ShowMenuDialog(playerid);
            }
            else
            {
                ShowPlayerDialog(playerid, DIALOG_MAIN_MENU_CREATE_CHARACTER_NAME, DIALOG_STYLE_LIST, "Master Account - New Character","What do you want your character to be called?\n(Firstname Lastname format).","Continue","Go Back");
            }   // Go back.
        }
    }
    return 1;
}
pawn Код:
(2457) : error 076: syntax error in the expression, or invalid function call
(2461) : error 036: empty statement
(2464) : error 001: expected token: ",", but found ";"
(2467) : error 017: undefined symbol "COLOR_YELLOW"
(2470) : error 029: invalid expression, assumed zero
(2501) : error 017: undefined symbol "sqlite_escape_string"
(2517 -- 2519) : error 017: undefined symbol "CivilianSpawn"
(2519) : warning 221: label name "Float" shadows tag name
(2519) : error 017: undefined symbol "CivX"
(2519) : error 029: invalid expression, assumed zero
(2519) : fatal error 107: too many error messages on one line
I need it in mysql with cacheing, I've tried but can't spot where the error is, or what callback/function to use.
Help is much appreciated!
Reply
#2

bump
Reply
#3

First of all, i should say i am a 0 at mysql for that expect help from others, but for others like undefined symbol issue, you havent defined the color yellow in your script or you have done a spelling mistake, define it or change the color name to those thats defined. Define the float by adding it in your script like new Float:CivX and so on. ( PS Dont use new again and again , once is enough. ) Also show the error lines please.
Reply
#4

In line 2461, remove the semicolon at the end of it:
pawn Код:
if(PlayerOwnsCharacter_Name(playerid, escapedstring)) //2461
In line 2464, remove the opened parenthesis from the arguments:
pawn Код:
format(query, sizeof(query), "DELETE FROM `Character` WHERE `cName` = '%s'", InsertPlayerUnderscoreString(inputtext)); //(InsertPlayerUnderscoreString(inputtext) //2464
Define the colour, not so hard to think of it:
pawn Код:
#define COLOR_YELLOW 0xFFFF00FF
sqlite_escape_string is a custom one, use mysql_format with '%e' placeholder to escape special characters.

The array CivilianSpawn is not defined, so declare it with its enum too.
Reply
#5

Thanks for the post, it worked but I can't get this fixed.

pawn Код:
if(CharacterExists(inputtext, InsertPlayerUnderscoreString))
pawn Код:
(2458) : error 076: syntax error in the expression, or invalid function call
Reply
#6

Is CharacterExists a function?
Reply
#7

Yes.
pawn Код:
forward CharacterExists(charactername[]);
public CharacterExists(charactername[])
{
    new query[128];
    format(query, sizeof(query), "SELECT * FROM `Character` WHERE ( `name` = '%s' )", charactername);
    if(cache_num_rows() >= 1)
    {
        return true;
    }
    return false;
}
Any ideas?
Reply
#8

In that function, there is 1 parameter and in the if statement, you used 2.

Except that, you call cache_num_rows function without having the query executed before.
Reply
#9

I added
pawn Код:
mysql_query(1, query);
Under
pawn Код:
new query[128];
    format(query, sizeof(query), "SELECT * FROM `Character` WHERE ( `name` = '%s' )", charactername);
Reply
#10

How do I set the player's spawn to a defined SpawnPoint. Example:
pawn Код:
if(Character[playerid][SpawnPoint] == 1) //North Caravan Park
        {
            TogglePlayerSpectating(playerid, false);
            if(Character[playerid][ClothesUsed] == 1)
            {
                SetSpawnInfo(playerid, 0, Character[playerid][Clothes1], 765.9069,361.9311,20.8550,174.3097, 0, 0, 0, 0, 0, 0);
                SpawnPlayer(playerid);
               
                if(Character[playerid][Faction] == 1)
                {
                    SetPlayerArmour(playerid, 100);
                }
                if(Character[playerid][Faction] == 2)
                {
                    GivePlayerWeapon(playerid, 42, 99999);
                }
                SetPlayerArmedWeapon(playerid, 0);
            }
            else if(Character[playerid][ClothesUsed] == 2)
            {
                SetSpawnInfo(playerid, 0, Character[playerid][Clothes2], 765.9069,361.9311,20.8550,174.3097, 0, 0, 0, 0, 0, 0);
                SpawnPlayer(playerid);
               
                if(Character[playerid][Faction] == 1)
                {
                    SetPlayerArmour(playerid, 100);
                }
                if(Character[playerid][Faction] == 2)
                {
                    GivePlayerWeapon(playerid, 42, 99999);
                }
                SetPlayerArmedWeapon(playerid, 0);
            }
            else if(Character[playerid][ClothesUsed] == 3)
            {
                SetSpawnInfo(playerid, 0, Character[playerid][Clothes3], 765.9069,361.9311,20.8550,174.3097, 0, 0, 0, 0, 0, 0);
                SpawnPlayer(playerid);
               
                if(Character[playerid][Faction] == 1)
                {
                    SetPlayerArmour(playerid, 100);
                }
                if(Character[playerid][Faction] == 2)
                {
                    GivePlayerWeapon(playerid, 42, 99999);
                }
                if(Character[playerid][Faction] == 3)
                {
                    GivePlayerWeapon(playerid, 43, 20);
                }
                SetPlayerArmedWeapon(playerid, 0);
            }
        }
I tried :
pawn Код:
SetSpawnInfo(playerid, 0, Character[playerid][Clothes1], Character[playerid][SpawnPoint] == 4, 0, 0, 0, 0, 0, 0);
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)