Jump to content
  • 0

Question

Posted (edited)

Salut, vreau si eu sa stiu cum pot sa rezolv erorile astea:

Citat

E:\x\pawno\new.pwn(31) : error 029: invalid expression, assumed zero
E:\x\pawno\new.pwn(124) : warning 217: loose indentation
E:\x\pawno\new.pwn(140) : warning 211: possibly unintended assignment
E:\x\pawno\new.pwn(150) : error 035: argument type mismatch (argument 3)
E:\x\pawno\new.pwn(151) : error 035: argument type mismatch (argument 3)
E:\x\pawno\new.pwn(152) : error 035: argument type mismatch (argument 3)
E:\x\pawno\new.pwn(177) : warning 203: symbol is never used: "OnGameModeInit"
Pawn compiler 3.2.3664              Copyright (c) 1997-2006, ITB CompuPhase


4 Errors.
[Finished in 0.4s]

Codul este

Citat

#include <a_samp>
#include <a_mysql>
new SQL=-1, gQuery[256], gString[256];

#define function%0(%1)    forward %0(%1);    public %0(%1)
#define SCM             SendClientMessage

#define COLOR_DARKRED 0xd80003FF
enum pInfo{
    pSQLID,
    pName[MAX_PLAYER_NAME],
    pPassword[32],
    pEmail[32],
    pGender
}
new PlayerInfo[MAX_PLAYERS][pInfo];
new IncercariParola[MAX_PLAYERS];

enum {
    //REGISTER
    DIALOG_REGISTER,
    DIALOG_EMAIL,
    DIALOG_GENDER,

    //LOGIN
    DIALOG_LOGIN
}

main()

public OnGameModeInit()
{
    SQL=mysql_connect("localhost", "root", "luna_db","");

    SetGameModeText("Blank Script");
    AddPlayerClass(0, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);
    return 1;
}

public OnGameModeExit()
{
    return 1;
}

public OnPlayerRequestClass(playerid, classid)
{
    SetPlayerPos(playerid, 1958.3783, 1343.1572, 15.3746);
    SetPlayerCameraPos(playerid, 1958.3783, 1343.1572, 15.3746);
    SetPlayerCameraLookAt(playerid, 1958.3783, 1343.1572, 15.3746);
    return 1;
}

public OnPlayerConnect(playerid) {
    IncercariParola[playerid]=0;

    gQuery[0]=EOS;
    mysql_format(SQL, gQuery, sizeof(gQuery), "SELECT * FROM `users` WHERE `name` = '%s' LIMIT 1", GetName(playerid));
    mysql_tquery(SQL, gQuery, "CheckAccount", "i", playerid);
    return 1;
}

public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[]){
    switch(dialogid){
        case DIALOG_REGISTER:{
            if(!response)
                return Kick(playerid);

            if(strlen(inputtext)<6 || strlen(inputtext)>32)
                return ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_PASSWORD, "Register", "Scrie o parola pentru a te putea inregistra(6-32 caractere):", "Select", "Cancel");

            gQuery[0]=EOS;
            mysql_format(SQL, gQuery, sizeof(gQuery), "INSERT INTO `users`(`Name`, `Password`) VALUES ('%s', '%s')", GetName(playerid), inputtext);
            mysql_tquery(SQL, gQuery, "insertAccount", "i", playerid);

            gString[0]=EOS;
            format(gString, sizeof(gString), "Parola ta contine %d caractere.", strlen(inputtext));
            SCM(playerid, -1, gString);

            format(PlayerInfo[playerid][pPassword], 32, inputtext);

            ShowPlayerDialog(playerid, DIALOG_EMAIL, DIALOG_STYLE_INPUT, "Email", "Adauga-ti adresa de email:", "Select", "Cancel");
        }
        case DIALOG_EMAIL:{
            if(!response)
                return Kick(playerid);

            if(strlen(inputtext)<6 || strlen(inputtext)>32)
                return ShowPlayerDialog(playerid, DIALOG_EMAIL, DIALOG_STYLE_INPUT, "Email", "Adauga-ti adresa de email:", "Select", "Cancel");

            gQuery[0]=EOS;
            mysql_format(SQL, gQuery, sizeof(gQuery), "UPDATE `users` SET `Email`='%s' WHERE `ID`='%d' ",inputtext, PlayerInfo[playerid][pSQLID]);
            mysql_tquery(SQL, gQuery, "", "");

            gString[0]=EOS;
            format(gString, sizeof(gString), "Email setat: %s.",inputtext);
            SCM(playerid, -1, gString);

            format(PlayerInfo[playerid][pEmail], 32, inputtext);

            ShowPlayerDialog(playerid, DIALOG_GENDER, DIALOG_STYLE_MSGBOX, "Gender", "Seteaza sexul caracterului tau:", "Masculin", "Feminin");
        }
        case DIALOG_GENDER:{
            switch(response) {
            case 0:{
                PlayerInfo[playerid][pGender]= 1;
                SendClientMessage(playerid,-1, "Sexul tau a fost setat: Feminin.");
            }
            case 1:{
                PlayerInfo[playerid][pGender]= 0;
                SendClientMessage(playerid,-1, "Sexul tau a fost setat: Masculin.");
            }
        }
            gQuery[0]=EOS;
            mysql_format(SQL, gQuery, sizeof(gQuery), "UPDATE `users` SET `Gender`='%d' WHERE `ID`='%d' ",PlayerInfo[playerid][pGender], PlayerInfo[playerid][pSQLID]);
            mysql_tquery(SQL, gQuery, "", "");

            SpawnPlayer(playerid);

    }
    case DIALOG_LOGIN: {
        if(!response)
            return Kick(playerid);

            mysql_format(SQL, gQuery, sizeof(gQuery), "SELECT * FROM `users` WHERE `name` = '%s' AND `Password`='%s' LIMIT 1", GetName(playerid), inputtext);
            mysql_tquery(SQL, gQuery, "onLogin", "i", playerid);
    }
}
    return 1;
}

function onLogin(playerid){
    switch(cache_num_rows()){
        case 0:{
            IncercariParola[playerid] ++;

            gString[0]=EOS;
            format(gString, sizeof(gString), "Parola incorecta! Mai ai %d incercari ramase!", IncercariParola[playerid]);
            SCM(playerid, COLOR_DARKRED, gString);

            if(IncercariParola[playerid]=3) Kick(playerid);
            else ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_PASSWORD, "Login", "Scrie parola pentru a te putea connecta pe server:", "Select", "Cancel");
        }
        case 1:{
            new
                result[64];

            PlayerInfo[playerid][pSQLID]= cache_get_field_content_int(0, "ID");
            PlayerInfo[playerid][pGender]= cache_get_field_content_int(0, "Gender");

            cache_get_field_content_int(0, "Name", result); format(PlayerInfo[playerid][pName], MAX_PLAYER_NAME, result);
            cache_get_field_content_int(0, "Password", result); format(PlayerInfo[playerid][pPassword], 32, result);
            cache_get_field_content_int(0, "Email", result); format(PlayerInfo[playerid][pEmail], 32, result);
            
            printf("%s(user: %d) s-a logat. [Gender: %d, Name: %s, Password: %s, Email: %S]", GetName(playerid), PlayerInfo[playerid][pSQLID], PlayerInfo[playerid][pGender], PlayerInfo[playerid][pPassword], PlayerInfo[playerid][pEmail]);
        }
    }
    return 1;
}

function insertAccount(playerid){
    PlayerInfo[playerid][pSQLID]= cache_insert_id();
    printf("%s s-a inregistrat cu SQLID-ul #%d.", GetName(playerid), PlayerInfo[playerid][pSQLID]);
    return 1;
}

function CheckAccount(playerid){
    switch(cache_num_rows()){
        case 0: ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_PASSWORD, "Register", "Scrie o parola pentru a te putea inregistra(6-32 caractere):", "Select", "Cancel");
        case 1: ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_PASSWORD, "Login", "Scrie parola pentru a te putea connecta pe server:", "Select", "Cancel");
    }
}

stock GetName(playerid){
    new playerName[MAX_PLAYER_NAME];
    GetPlayerName(playerid, playerName, MAX_PLAYER_NAME);
    return playerName;
}

 

Edited by Iamcarrot

1 answer to this question

Recommended Posts

  • 0
Posted (edited)
#include <a_samp>
#include <a_mysql>
new SQL=-1, gQuery[256], gString[4500];

#define function%0(%1)    forward %0(%1);    public %0(%1)
#define SCM             SendClientMessage

#define COLOR_DARKRED 0xd80003FF
enum pInfo{
    pSQLID,
    pName[MAX_PLAYER_NAME],
    pPassword[32],
    pEmail[32],
    pGender
}
new PlayerInfo[MAX_PLAYERS][pInfo];
new IncercariParola[MAX_PLAYERS];

enum {
    //REGISTER
    DIALOG_REGISTER,
    DIALOG_EMAIL,
    DIALOG_GENDER,

    //LOGIN
    DIALOG_LOGIN
}

main()
{
    print("\n----------------------------------");
    print(Gamemode loaded succesfully.);
    print("----------------------------------\n");
  //de aici poti sterge tot, poti lasa doar acoladele {} ca sa nu iti dea eroare.
}

public OnGameModeInit()
{
    new liTick = GetTickCount();
    SQL = mysql_connect("localhost", "root", "luna_db","");

    SetGameModeText("Blank Script");
    AddPlayerClass(0, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);
    printf("[ CALLBACK: OnGameModeInit ] Executat in %dms.", GetTickCount( ) - liTick);
    return 1;
}

public OnGameModeExit()
{
    return 1;
}

public OnPlayerRequestClass(playerid, classid)
{
    SetPlayerPos(playerid, 1958.3783, 1343.1572, 15.3746);
    SetPlayerCameraPos(playerid, 1958.3783, 1343.1572, 15.3746);
    SetPlayerCameraLookAt(playerid, 1958.3783, 1343.1572, 15.3746);
    return 1;
}

public OnPlayerConnect(playerid) {
    IncercariParola[playerid]=0;

    gQuery[0]=EOS;
    mysql_format(SQL, gQuery, sizeof(gQuery), "SELECT * FROM `users` WHERE `name` = '%s' LIMIT 1", GetName(playerid));
    mysql_tquery(SQL, gQuery, "CheckAccount", "i", playerid);
    return 1;
}

public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[]){
    switch(dialogid)
    {
        case DIALOG_REGISTER:
        {
            if(!response)
                return Kick(playerid);

            if(strlen(inputtext)<6 || strlen(inputtext)>32)
                return ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_PASSWORD, "Register", "Scrie o parola pentru a te putea inregistra(6-32 caractere):", "Select", "Cancel");

            gQuery[0]=EOS;
            mysql_format(SQL, gQuery, sizeof(gQuery), "INSERT INTO `users`(`Name`, `Password`) VALUES ('%s', '%s')", GetName(playerid), inputtext);
            mysql_tquery(SQL, gQuery, "insertAccount", "i", playerid);

            gString[0]=EOS;
            format(gString, sizeof(gString), "Parola ta contine %d caractere.", strlen(inputtext));
            SCM(playerid, -1, gString);

            format(PlayerInfo[playerid][pPassword], 32, inputtext);

            ShowPlayerDialog(playerid, DIALOG_EMAIL, DIALOG_STYLE_INPUT, "Email", "Adauga-ti adresa de email:", "Select", "Cancel");
        }
        case DIALOG_EMAIL:
        {
            if(!response)
                return Kick(playerid);

            if(strlen(inputtext)<6 || strlen(inputtext)>32)
                return ShowPlayerDialog(playerid, DIALOG_EMAIL, DIALOG_STYLE_INPUT, "Email", "Adauga-ti adresa de email:", "Select", "Cancel");

            gQuery[0]=EOS;
            mysql_format(SQL, gQuery, sizeof(gQuery), "UPDATE `users` SET `Email`='%s' WHERE `ID`='%d' ",inputtext, PlayerInfo[playerid][pSQLID]);
            mysql_tquery(SQL, gQuery, "", "");

            gString[0]=EOS;
            format(gString, sizeof(gString), "Email setat: %s.",inputtext);
            SCM(playerid, -1, gString);

            format(PlayerInfo[playerid][pEmail], 32, inputtext);

            ShowPlayerDialog(playerid, DIALOG_GENDER, DIALOG_STYLE_MSGBOX, "Gender", "Seteaza sexul caracterului tau:", "Masculin", "Feminin");
        }
        case DIALOG_GENDER:
        {
            switch(response) {
                case 0:{
                    PlayerInfo[playerid][pGender]= 1;
                    SendClientMessage(playerid,-1, "Sexul tau a fost setat: Feminin.");
                }
                case 1:{
                    PlayerInfo[playerid][pGender]= 0;
                    SendClientMessage(playerid,-1, "Sexul tau a fost setat: Masculin.");
                }
            }
            gQuery[0]=EOS;
            mysql_format(SQL, gQuery, sizeof(gQuery), "UPDATE `users` SET `Gender`='%d' WHERE `ID`='%d' ",PlayerInfo[playerid][pGender], PlayerInfo[playerid][pSQLID]);
            mysql_tquery(SQL, gQuery, "", "");

            SpawnPlayer(playerid);
        }
        case DIALOG_LOGIN: {
            if(!response) return Kick(playerid);

            mysql_format(SQL, gQuery, sizeof(gQuery), "SELECT * FROM `users` WHERE `name` = '%s' AND `Password`='%s' LIMIT 1", GetName(playerid), inputtext);
            mysql_tquery(SQL, gQuery, "onLogin", "i", playerid);
        }
    }
    return 1;
}

function onLogin(playerid){
    switch(cache_num_rows())
    {
        case 0:
        {
            IncercariParola[playerid] ++;

            gString[0] = EOS;
            format(gString, sizeof(gString), "Parola incorecta! Mai ai %d incercari ramase!", IncercariParola[playerid]);
            SCM(playerid, COLOR_DARKRED, gString);

            if(IncercariParola[playerid] == 3) Kick(playerid);
            else ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_PASSWORD, "Login", "Scrie parola pentru a te putea connecta pe server:", "Select", "Cancel");
        }
        case 1:
        {
            new
                result[64];

            PlayerInfo[playerid][pSQLID] = cache_get_field_content_int(0, "ID", SQL);
            PlayerInfo[playerid][pGender] = cache_get_field_content_int(0, "Gender", SQL);

            cache_get_field_content_int(0, "Name", result); format(PlayerInfo[playerid][pName], MAX_PLAYER_NAME, result);
            cache_get_field_content_int(0, "Password", result); format(PlayerInfo[playerid][pPassword], 32, result);
            cache_get_field_content_int(0, "Email", result); format(PlayerInfo[playerid][pEmail], 32, result);
            
            printf("%s(user: %d) s-a logat. [Gender: %d, Name: %s, Password: %s, Email: %S]", GetName(playerid), PlayerInfo[playerid][pSQLID], PlayerInfo[playerid][pGender], PlayerInfo[playerid][pPassword], PlayerInfo[playerid][pEmail]);
        }
    }
    return 1;
}

function insertAccount(playerid){
    PlayerInfo[playerid][pSQLID]= cache_insert_id();
    printf("%s s-a inregistrat cu SQLID-ul #%d.", GetName(playerid), PlayerInfo[playerid][pSQLID]);
    return 1;
}

function CheckAccount(playerid){
    switch(cache_num_rows()){
        case 0: ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_PASSWORD, "Register", "Scrie o parola pentru a te putea inregistra(6-32 caractere):", "Select", "Cancel");
        case 1: ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_PASSWORD, "Login", "Scrie parola pentru a te putea connecta pe server:", "Select", "Cancel");
    }
}

stock GetName(playerid){
    new playerName[MAX_PLAYER_NAME];
    GetPlayerName(playerid, playerName, MAX_PLAYER_NAME);
    return playerName;
}

Sper ca te-am ajutat.

Edited by BaFFyJunior

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. For more details you can also review our Terms of Use and Privacy Policy.