server crash (mysql problem??)
#1

hi...
I'm using a msql db and I made a /setlvl cmd...
pawn Код:
new name[MAX_PLAYER_NAME]; GetPlayerName(playerid, name, sizeof(name));
    if((PlayerData[playerid][Level] >= 3) || (IsPlayerAdmin(playerid) && !strcmp(name, "MrX", true)))
    {
        new tmp[256], idx, pid;
        tmp = strtok(params, idx);
        if(!strlen(tmp)) return SendClientMessage(playerid, GREY, "Useage: /setlvl [id/name] [0-3]");
        if(!IsNumeric(tmp)) pid = GetPlayerIDFromName(tmp);
        else pid = strval(tmp);
        if(!IsPlayerConnected(pid)) return SendClientMessage(playerid, GREY, "Player not found");
        tmp = strtok(params, idx);
        if(!strlen(tmp)) return SendClientMessage(playerid, GREY, "Useage: /setlvl [id/name] [0-3]");
        if(!IsNumeric(tmp) || strval(tmp) > 3 || strval(tmp) < 0) return SendClientMessage(playerid, GREY, "Level must be 0 - 3");
        new lvl = strval(tmp);
        new name2[MAX_PLAYER_NAME], string[100], query[150];
        GetPlayerName(pid, name2, sizeof(name2));
        format(string, sizeof(string), "*You set %s's level from %d to %d", name2, PlayerData[pid][Level], lvl);
        SendClientMessage(playerid, GREY, string);
        format(string, sizeof(string), "*Your level was set from %d to %d", PlayerData[pid][Level], lvl);
        SendClientMessage(pid, GREY, string);
        format(string, sizeof(string), "[SERVER]%s changed %s level from %d to %d", name, name2, PlayerData[pid][Level], lvl);
        Log(string);
        print(string);
        format(query, sizeof(query), "UPDATE `User` SET `Level`='%d' WHERE `Name`='%s'", lvl, name2);
        mysql_query(query);
        PlayerData[pid][Level] = lvl;
    }
always when I use it my server crashes... any idea why?
Reply
#2

Does it say anything on compile?
Reply
#3

nope.. as far as I know the script is correct... I guess it's something caused by mysql...
Reply
#4

Before you added that, was it still crashing?
Reply
#5

no?.. dude I'm no noob that can't handle sa-mp stuff... I know that this command is the only thing that causes the crash. Additionally i said "Always when I use the command it crashes"....
Reply
#6

What exactly does the Log function ?
Reply
#7

saves in an external log:P... I'm using it because the server_logs is fucked up with admin chat, radio, etc..
pawn Код:
public Log(log[])
{
    new day, year, month, hour, minute, second, string[300];
    getdate(year, month, day);
    gettime(hour, minute, second);
    if(!fexist("Logs/Log.txt"))
    {
        new File:fi = fopen("Logs/Log.txt", io_write);
        fclose(fi);
    }
    format(string, sizeof(string), "[%d/%d/%d - %d:%d.%d]%s\r\n", day, month, year, hour, minute, second, log);
    new File:fi = fopen("Logs/Log.txt", io_append);
    fwrite(fi, string);
    fclose(fi);
    return 1;
}
Reply
#8

There is a '%d' with the ' marks which arnt needed for an interger. Can't paste the line because i'm on my iPod but it's near the bottom, hopefully that should fix it.
Reply
#9

never new it's not needed lol... well it doesn't fix it though -.-
Reply
#10

Does the Log folder exist ?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)