MySQL Problem
#1

hello.

have me small problem in mysql.

here the code:

pawn Code:
public OnPlayerDeath(playerid, killerid, reason)
{
    ResetPlayerWeapons(playerid);
    format(String,256,"UPDATE `Users` SET `Death`=%i WHERE `Nick`='%s'",GetPlayerDeath(playerid) + 1,GetName(playerid));
    mysql_query(String);
    if(IsPlayerConnected(killerid))
    {
        SendDeathMessage(killerid,playerid,reason);
        format(String,256,"UPDATE `Users` SET `Kills`=%i WHERE `Nick`='%s'",GetPlayerKills(killerid) + 1,GetName(killerid));
        mysql_query(String);
        if(GetPlayerKills(killerid) == Levels[GetPlayerLevel(killerid)+1])
        {
            format(String,256,"!%i тмд мшод %s бшлеъйре , дщзчп",GetPlayerLevel(killerid) + 1,GetName(killerid));
            SendClientMessageToAllEx(killerid,c_orange,String);
            format(String,256,".%i бшлеъйре , тмйъ мшод",GetPlayerLevel(killerid) + 1);
            SendClientMessage(killerid,c_orange,String);
            format(String,256,"/Level Commands %i - тм оръ мцфеъ бфчегеъ дзгщеъ мшод щмк дчщ",GetPlayerLevel(killerid) + 1);
            SendClientMessage(killerid,c_orange,String);
            format(String,256,"UPDATE `Users` SET `Level`=%i WHERE `Nick`='%s'",GetPlayerLevel(playerid) + 1,GetName(playerid));
            mysql_query(String);
        }
    }
    ResetPlayerMoney(playerid);
    return true;
}
and here the stock GetPlayerKills And GetPlayerDeath:

pawn Code:
stock GetPlayerKills(playerid)
{
    new Kills,Query[256];
    format(Query,256,"SELECT `Kills` FROM `Users` WHERE `Nick`='%s'",GetName(playerid));
    mysql_query(Query);
    mysql_store_result();
    if(mysql_retrieve_row()) Kills = mysql_fetch_int();
    mysql_free_result();
    return Kills;
}
stock GetPlayerDeath(playerid)
{
    new Death,szQuery[256];
    format(szQuery,256,"SELECT `Death` FROM `Users` WHERE `Nick`='%s'",GetName(playerid));
    mysql_query(szQuery);
    mysql_store_result();
    if(mysql_retrieve_row()) Death = mysql_fetch_int();
    mysql_free_result();
    return Death;
}
The problem is, it raises the kills of the player table.

Thanks in advance helpers
Reply
#2

You don't need GetPlayerDeath and GetPlayerKills.

pawn Code:
public OnPlayerDeath(playerid, killerid, reason)
{
    ResetPlayerWeapons(playerid);
    format(String,256,"UPDATE `Users` SET Death=Death+1 WHERE `Nick`='%s'",GetName(playerid));
    mysql_query(String);
    if(IsPlayerConnected(killerid))
    {
        SendDeathMessage(killerid,playerid,reason);
        format(String,256,"UPDATE `Users` SET Kills=Kills+1 WHERE `Nick`='%s'",GetName(killerid));
        mysql_query(String);
        if(GetPlayerKills(killerid) == Levels[GetPlayerLevel(killerid)+1])
        {
            format(String,256,"!%i o`i`д i`?од %s б?лa*ъй?a* , дu`зчi"",GetPlayerLevel(killerid) + 1,GetName(killerid));
            SendClientMessageToAllEx(killerid,c_orange,String);
            format(String,256,"
.%i б?лa*ъй?a* , o`i`йъ i`?од",GetPlayerLevel(killerid) + 1);
            SendClientMessage(killerid,c_orange,String);
            format(String,256,"
/Level Commands %i - o`i` о?ъ i`цфa*ъ бфчa*a~a*ъ дзa~u`a*ъ i`?од u`i`e^ дчu`",GetPlayerLevel(killerid) + 1);
            SendClientMessage(killerid,c_orange,String);
            format(String,256,"
UPDATE `Users` SET Level=Level+1 WHERE `Nick`='%s'",GetName(playerid));
            mysql_query(String);
        }
    }
    ResetPlayerMoney(playerid);
    return true;
}
Reply
#3

thank you very much man
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)