Strange 0.3z bug
#1

I don't know if it is only with me, but my gamemode (it's only 300 lines long) displays the special characters (г, й, з) all wrong, like a textdraw, on the normal chat.


Any ideas why?

Thanks in advance.
Reply
#2

Do you have any code to show us? 0_o
Reply
#3

Sure, here's my WHOLE gamemode:

pawn Код:
/*                                                                    *\
    DIRETO DA FORJA DE GM'S FODAS...   
                                 ... O LENDБRIO SANTA FARIA ROLEPLAY!
                                 
                    CRЙDITOS TODOS AO LELETE
                            GM DO ZERO!
                            VAMO Q VAMO
\*                                                                    */
                           
#include <a_samp>
#include <a_mysql>
//##############################################################################################
#define     SERVER_NAME     "Santa Faria Roleplay"
#define     SERVER_VERSION  "SF-RP 1.0"
#define     SERVER_MAP      "SF-RP 1.0"
#define     SERVER_TEXT     "hostname [0.3z] Santa Faria Roleplay [BR]"
#define     LAST_UPDATE     "13 de Fevereiro de 2014"
#define     MYSQL_HOST      "localhost"
#define     MYSQL_USER      "sfrp"
#define     MYSQL_DB        "sfrp"
#define     MYSQL_PASS      ""
#undef      MAX_PLAYERS
#define     MAX_PLAYERS     (50)
#define     DIALOG_NULL     (1)
#define     DIALOG_LOGIN    (2)
#define     COLOR_SYSTEM    0xA9C4E4FF
#define     COLOR_ERROR     0xAFAFAFFF
#define     COLOR_WARNING   0xFFAA00FF
//##############################################################################################
forward SendSuccessMessage(playerid, msg[]);
forward SendErrorMessage(playerid, msg[]);
forward SendSystemMessage(playerid, msg[]);
forward SendWarningMessage(playerid, msg[]);
forward SendRPMessage(playerid, msg[]);
forward OnPlayerLogin(playerid);
forward OnPlayerRegister(playerid);
forward CheckAccount(playerid);
forward CheckBan(playerid);
//##############################################################################################
new db;
//##############################################################################################
main()
{
    print("[X] LeLeTe apresenta, do zero... [X]");
    print(SERVER_NAME);
    print(SERVER_VERSION);
    printf("Atualizado em: %s", LAST_UPDATE);
    print("[X] A LENDA! [X]");
}
//##############################################################################################
enum P_DATA
{
    P_PASS[24],
    P_NAME[24],
    P_ID
}
new PlayerData[MAX_PLAYERS][P_DATA];
//##############################################################################################
stock ReturnPlayerName(playerid)
{
    new string[24];
    GetPlayerName(playerid, string, 24);
    return string;
}

stock ReturnRPName(playerid)
{
    new str, idx;
    GetPlayerName(playerid, str[0], 24);
    idx = strfind( str[0], "_" );
    str[idx] = ' ';
    return str;
}

stock StartTutorial(playerid)
{
    return playerid;
}

stock BanReason(playerid, reason[])
{
    new str[256], pIP[16], safereason[128];
    mysql_real_escape_string(safereason, reason, db);
    GetPlayerIp(playerid, pIP, 16);
    format(str, 256, "INSERT INTO bans (IP, Reason) VALUES('%s', '%s')", pIP, reason);
    mysql_function_query(db, str, false, "", "");
    BanEx(playerid, reason);
    return 1;
}

stock PlayerLog(playerid, reason[])
{
    new string[384];
    mysql_format(db, string, 384, "INSERT INTO playerlogs (Name, Log) VALUES('%e', '%e')", ReturnPlayerName(playerid), reason);
    mysql_function_query(db, string, false, "", "");
    return 1;
}
//##############################################################################################
public SendErrorMessage(playerid, msg[])
{

    new lengths[128], length2[128], message[128];
    strmid(lengths, msg, 0, 115);
    strmid(length2, msg, 114, 256);
    if(strlen(msg) > 96)
    {
        format(message, 128, "[ERRO] %s ...", lengths);
        SendClientMessage(playerid, COLOR_ERROR, message);
        PlayerLog(playerid, message);
        format(message, 128, "... %s", length2);
        SendClientMessage(playerid, COLOR_ERROR, message);
        PlayerLog(playerid, message);
    }
    else
    {
        format(message, 128, "[ERRO] %s", msg);
        SendClientMessage(playerid, COLOR_ERROR, message);
        PlayerLog(playerid, message);
    }
    return 1;
}

public SendSystemMessage(playerid, msg[])
{
    new lengths[128], length2[128], message[128];
    strmid(lengths, msg, 0, 96);
    strmid(length2, msg, 95, 256);
    if(strlen(msg) > 91)
    {
        format(message, 128, "[{C2A2DA}#{A9C4E4}] %s ...", lengths);
        SendClientMessage(playerid, COLOR_SYSTEM, message);
        PlayerLog(playerid, message);
        format(message, 128, "... %s", length2);
        SendClientMessage(playerid, COLOR_SYSTEM, message);
        PlayerLog(playerid, message);
    }
    else
    {
        format(message, 128, "[[{C2A2DA}#{A9C4E4}] %s", msg);
        SendClientMessage(playerid, COLOR_SYSTEM, message);
        PlayerLog(playerid, message);
    }
    return 1;
}

public SendWarningMessage(playerid, msg[])
{
    new lengths[128], length2[128], message[128];
    strmid(lengths, msg, 0, 118);
    strmid(length2, msg, 117, 256);
    if(strlen(msg) > 96)
    {
        format(message, 128, "[!] %s ...", lengths);
        SendClientMessage(playerid, COLOR_WARNING, message);
        PlayerLog(playerid, message);
        format(message, 128, "... %s", length2);
        SendClientMessage(playerid, COLOR_WARNING, message);
        PlayerLog(playerid, message);
    }
    else
    {
        format(message, 128, "[!] %s", msg);
        SendClientMessage(playerid, COLOR_WARNING, message);
        PlayerLog(playerid, message);
    }
    return 1;
}

public SendRPMessage(playerid, msg[])
{
    new lengths[128], length2[128], message[128];
    strmid(lengths, msg, 0, 119);
    strmid(length2, msg, 118, 256);
    if(strlen(msg) > 96)
    {
        format(message, 128, "* %s ...", lengths);
        SendClientMessage(playerid, 0xC2A2DAFF, message);
        PlayerLog(playerid, message);
        format(message, 128, "... %s", length2);
        SendClientMessage(playerid, 0xC2A2DAFF, message);
        PlayerLog(playerid, message);
    }
    else
    {
        format(message, 128, "* %s", msg);
        SendClientMessage(playerid, 0xC2A2DAFF, message);
        PlayerLog(playerid, message);
    }
    return 1;
}

public OnQueryError(errorid, error[], callback[], query[], connectionHandle)
    return printf("[MYSQL] ERRO %d - \"%s\" - \"%s\" - \"%s\" - %d", errorid, error,  callback, query, connectionHandle);

public CheckAccount(playerid)
{
    new rows, fields, result[24];
    cache_get_data(rows, fields);
    if(!rows) SetPVarInt(playerid, "AccountExists", 0);
    else SetPVarInt(playerid, "AccountExists", 1);
    cache_get_row(0, 0, result);
    SetPVarString(playerid, "Pass", result);
    return 1;
}

public CheckBan(playerid)
{
    new rows, fields, string[128];
    cache_get_data(rows, fields);
    if(!rows) return 1;
    else
    {
        new pIP[16], reason[128];
        GetPlayerIp(playerid, pIP, 16);
        cache_get_row(0, 0, reason);
        format(string, 128, "Foi detectado que seu IP ({C2A2DA}%s{A9C4E4}) se encontra {FF0000}BANIDO{a9C4e4} de nosso servidor. Motivo do Ban:", pIP);
        SendSystemMessage(playerid, string);
        format(string, 128, "{c2a2da}%s", reason);
        SendSystemMessage(playerid, string);
        SendSystemMessage(playerid, "Caso seja um erro, tire um print desta mensagem e reporte no fуrum. Vocк serб desconectado imediatamente.");
        BanEx(playerid, "[SISTEMA] Tentativa de evasгo de ban");
    }
    return 1;
}

public OnPlayerRegister(playerid)
{
    PlayerData[playerid][P_ID] = mysql_insert_id();
    SetPVarInt(playerid, "AccountExists", 1);
    SetPVarInt(playerid, "Logged", 1);
    SendSystemMessage(playerid, "Bem vindo ao tutorial do Santa Faria Roleplay. Preste atenзгo nas informaзхes na tela.");
    StartTutorial(playerid);
    return 1;
}

public OnPlayerLogin(playerid)
{
    new tick = tickcount();
    new result[128], pass[24];
    GetPVarString(playerid, "Pass", pass, 24);
    cache_get_row(0, 2, result);
    if(!strcmp(result, pass, true, 24))
    {
        cache_get_row(0, 0, PlayerData[playerid][P_ID]);
        cache_get_row(0, 1, PlayerData[playerid][P_NAME]);
        cache_get_row(0, 2, PlayerData[playerid][P_PASS]);
        printf("%d %s %s %d", PlayerData[playerid][P_ID], PlayerData[playerid][P_NAME], PlayerData[playerid][P_PASS], tickcount()-tick);
    }
    else
    {
        new la = GetPVarInt(playerid, "LoginAttempts");
        SetPVarInt(playerid, "LoginAttempts", la+1);
        if(la == 4)
        {
            SendSystemMessage(playerid, "Seu IP serб banido imediatamente por errar quatro vezes sua senha.");
            BanEx(playerid, "[SISTEMA] Errou quatro vezes a senha.");
            return 1;
        }
        return ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_PASSWORD, "{C2A2DA}#{A9C4E4} Santa Faria Roleplay", result, "Continuar", "Sair do Servidor");
    }
    return 1;
}
//##############################################################################################

public OnGameModeInit()
{
    #if defined DEBUG
        mysql_debug(1);
        print("[DEBUG] OnGameModeInit()");
    #endif
    db = mysql_connect("localhost", "sprp", "sprp", "");
    if(db == 0) return print("[ERRO] A conexгo com o banco de dados nгo pode ser estabelecida. Servidor desligando..."), 0;
    ShowPlayerMarkers(0);
    EnableStuntBonusForAll(0);
    DisableInteriorEnterExits();
    SetNameTagDrawDistance(15.0);
    AddPlayerClass(183, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
    SetGameModeText(SERVER_VERSION);
    SendRconCommand("mapname Santa Faria, SP");
    SendRconCommand(SERVER_TEXT);
    mysql_function_query(db, "SELECT * FROM playerdata", false, "", "");
    return 1;
}


public OnGameModeExit()
{
    return 1;
}

public OnPlayerRequestClass(playerid, classid)
{
    SpawnPlayer(playerid);
    return 1;
}

public OnPlayerConnect(playerid)
{
    new string[70], pIP[16];
    GetPlayerIp(playerid, pIP, 16);
    format(string, 70, "SELECT Reason FROM bans WHERE IP = '%s'", pIP);
    mysql_function_query(db, string, true, "CheckBan", "i", playerid);
    for(new i = 0; i < _:P_DATA; i++)
    {
        PlayerData[playerid][P_DATA:i] = 0;
    }
    SendSystemMessage(playerid, "Bem vindo ao Santa Faria Roleplay! O sistema estб carregando seus dados...");
    format(string, 70, "SELECT Password FROM playerdata WHERE Name = '%s'", ReturnPlayerName(playerid));
    mysql_function_query(db, string, true, "CheckAccount", "i", playerid);
    return 1;
}

public OnPlayerDisconnect(playerid, reason)
{
    return 1;
}

public OnPlayerSpawn(playerid)
{
    if(!GetPVarInt(playerid, "Logged"))
    {  
        if(!GetPVarInt(playerid, "AccountExists"))
            return ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_PASSWORD, "{C2A2DA}#{A9C4E4} Santa Faria Roleplay", "Bem vindo!\nPor favor, registre uma senha abaixo para continuar.\nATENЗГO! A senha tem um limite de 24 caracteres.", "Registrar", "Sair");
        else
            return ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_PASSWORD, "{C2A2DA}#{A9C4E4} Santa Faria Roleplay", "Bem vindo!\nPor favor, digite sua senha abaixo para continuar.", "Continuar", "Sair");
    }
    return 1;
}

public OnPlayerDeath(playerid, killerid, reason)
{
    return 1;
}

public OnVehicleSpawn(vehicleid)
{
    return 1;
}

public OnVehicleDeath(vehicleid, killerid)
{
    return 1;
}

public OnPlayerText(playerid, text[])
{
    return 1;
}

public OnPlayerCommandText(playerid, cmdtext[])
{
    if (strcmp("/mycommand", cmdtext, true, 10) == 0)
    {
        // Do something here
        return 1;
    }
    return 0;
}

public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
    return 1;
}

public OnPlayerExitVehicle(playerid, vehicleid)
{
    return 1;
}

public OnPlayerStateChange(playerid, newstate, oldstate)
{
    return 1;
}

public OnPlayerEnterCheckpoint(playerid)
{
    return 1;
}

public OnPlayerLeaveCheckpoint(playerid)
{
    return 1;
}

public OnPlayerEnterRaceCheckpoint(playerid)
{
    return 1;
}

public OnPlayerLeaveRaceCheckpoint(playerid)
{
    return 1;
}

public OnRconCommand(cmd[])
{
    return 1;
}

public OnPlayerRequestSpawn(playerid)
{
    return 1;
}

public OnObjectMoved(objectid)
{
    return 1;
}

public OnPlayerObjectMoved(playerid, objectid)
{
    return 1;
}

public OnPlayerPickUpPickup(playerid, pickupid)
{
    return 1;
}

public OnVehicleMod(playerid, vehicleid, componentid)
{
    return 1;
}

public OnVehiclePaintjob(playerid, vehicleid, paintjobid)
{
    return 1;
}

public OnVehicleRespray(playerid, vehicleid, color1, color2)
{
    return 1;
}

public OnPlayerSelectedMenuRow(playerid, row)
{
    return 1;
}

public OnPlayerExitedMenu(playerid)
{
    return 1;
}

public OnPlayerInteriorChange(playerid, newinteriorid, oldinteriorid)
{
    return 1;
}

public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
    return 1;
}

public OnRconLoginAttempt(ip[], password[], success)
{
    return 1;
}

public OnPlayerUpdate(playerid)
{
    return 1;
}

public OnPlayerStreamIn(playerid, forplayerid)
{
    return 1;
}

public OnPlayerStreamOut(playerid, forplayerid)
{
    return 1;
}

public OnVehicleStreamIn(vehicleid, forplayerid)
{
    return 1;
}

public OnVehicleStreamOut(vehicleid, forplayerid)
{
    return 1;
}

public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
    switch (dialogid)
    {
        case 1: return 1;
        case 2:
        {
            if(!response) return SendSystemMessage(playerid, "Vocк serб kickado pois decidiu nгo logar no servidor."), Kick(playerid);
            if(!GetPVarInt(playerid, "AccoutnExists"))
            {
                new string[123], safename[24], safeinput[24];
                mysql_real_escape_string(ReturnPlayerName(playerid), safename, db);
                mysql_real_escape_string(inputtext, safeinput, db);
                format(string, 123, "INSERT INTO playerdata (Name, Password) VALUES('%s', '%s')", safename, safeinput);
                mysql_function_query(db, string, true, "OnPlayerRegister", "i", playerid);
            }
            else
            {
                new string[123];
                format(string, 123, "SELECT * FROM playerdata WHERE Name = '%s'", ReturnPlayerName(playerid), inputtext);
                mysql_function_query(db, string, true, "OnPlayerLogin", "i", playerid);
            }
        }
    }
    return 1;
}

public OnPlayerClickPlayer(playerid, clickedplayerid, source)
{
    return 1;
}
Reply
#4

Does not happen to me:

Reply
#5

Very, VERY odd.

I've shown all my script. Perhaps it's a function i've fucked up?

Anyone can shed a light?
Reply
#6

Do you use Notepad++ or pawno ?

If you use Notepad++ you have to change the encoding.
Reply
#7

I must mention that in my gamemode I render the message of the player before using it, so it does not use native chat.

pawn Код:
for(new i = 0; i < PLAYERS; i ++)
        {
            if(IsPlayerConnected(i))
            {
                if(GetPVarInt(i,"AccountLevel") >= 4)
                {
                    format(msg, sizeof(msg),"{BBBBBB}(%s) {%s}%s (%d){FFFFFF}: %s",accountname, GetPlayerTeamHexColor(playerid),PlayerName(playerid),playerid, text);
                    RenderMessage(i, 0xFFFFFFFF, msg);
                }
                else
                {
                    format(msg, sizeof(msg),"{%s}%s{FFFFFF}: %s",GetPlayerTeamHexColor(playerid),PlayerName(playerid), text);
                    RenderMessage(i, 0xFFFFFFFF, msg);
                }
            }
        }
Try doing something similar, render the message of the player and use a custom function (such as SendClientMessage) to send the text, return 0 at OnPlayerText.

Also a little function of mine:

pawn Код:
stock RenderMessage(top, color, const text[])
{
    new temp[156], tosearch = 0, colorint, posscolor, lastcol[12];
    new mess[356], colors, tempc; format(mess, 356, "%s",text);

    while(strlen(mess) > 0)
    {
        if(strlen(mess) < 140)
        {
            SendClientMessage(top, color, mess);
            break;
        }
   
        strmid(temp, mess, 0, 128);
        while(strfind(temp, "{", true) != -1)
        {
            tempc = strfind(temp, "{", true);
            if(temp[tempc+7] == '}')
            {
                colors ++;
                strdel(temp, tempc, tempc+7);
            }
            else
            {
                temp[tempc] = '0';
                continue;
            }
        }
        temp = "";
   
        if(strfind(mess," ",true,100+colors*8) != -1)
        {
            tosearch = strfind(mess," ",true,100+colors*8)+1;
            while(tosearch > 140)
            {
                colors --;
                tosearch = strfind(mess," ",true,100+colors*8)+1;
            }
        }
       
        if(strfind(mess,"{",true) != -1) //color codes detection , YAY
        {
            posscolor = strfind(mess,"{",true);

            if(mess[posscolor+7] == '}') //detected one color
                colorint = posscolor;
               
            while(strfind(mess,"{",true,colorint+1) != -1) //repeat until none are found
            {
                posscolor = strfind(mess,"{",true,colorint+1);
                if(posscolor > tosearch) //if next color will be on the other line, use last color found to render on the next line
                {
                    posscolor = colorint;
                    break;
                }
                if(mess[posscolor+7] == '}') //if found, then assign the color
                {
                    colorint = posscolor;
                }
                else
                {
                    posscolor = colorint; //else, leave the last color.
                    break;
                }
            }

            if(colorint == posscolor) //if the color position equals the one that was found
                strmid(lastcol,mess,colorint,colorint+8); //get the last used color string.
        }

        strmid(temp, mess, 0, tosearch);
        SendClientMessage(top, color, temp);
        strdel(mess, 0, tosearch);
        strins(mess, lastcol, 0); //insert last used color into the new line to be processed.


        temp = "";
        tosearch = 0;
        colors = 0;
    }
    return 1;
}
Will split a message into many lines as needed after a space is found after the 100th character. Keeps the last color code used too.
Reply
#8

@anou1

Which encoding should i use?

@Cuerv0

Nice function, man! Thanks for the tip, i appreciate it.
Reply
#9

If you script on Notepad++, if I remember you have to use ANCI. Try it and tell us
Reply
#10

@anou1

You sir, are freaking awesome.

thanks for the tip, it worked now!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)