[HELP]Damages Issue
#1

Код:
new fetch[256];
format(query, sizeof(query), "SELECT * FROM `damages` WHERE `pid` = '%s'", playerid);
cache_get_field_content(0, "area", fetch);
format(area, 79, "%s", fetch);
cache_get_field_content(0, "damage", fetch);
format(damage, 79, "%f", fetch);
cache_get_field_content(0, "weapon", fetch);
format(weapon, 79, "%s", fetch);
cache_get_field_content(0, "shooter", fetch);
format(shooter, 79, "%s", fetch);
mysql_function_query(dbHandle, query, false, "", "");
new gText[1000], fstr[45];
format(fstr, sizeof(fstr), "%d damage from %s to the %s\n", damage, weapon, area);
Код:
format(query, sizeof(query), "INSERT INTO `damages` (pid, area, damage, weapon, shooter) VALUES ('%d', '%s', '%f', '%s', '%s')",Target,GetBodyPartName(Target + 3),HealthLost,GetPlayerWeapon(Shooter),GetName(Shooter));
mysql_function_query(dbHandle, query, false, "", "");
Essentially what I aimed to do was to insert damages whenever the player lost health. Although that all works well, when selecting from the damages in order to display them, the display doesn't work.
Reply
#2

Quote:
Originally Posted by XVlaDX
Посмотреть сообщение
pawn Код:
format(query, sizeof(query), "SELECT * FROM `damages` WHERE `pid` = '%s'", playerid);
"`pid` = '%s'", playerid);"

playerid is a string ?, okay..

use "%d" for integers like playerid.
Reply
#3

You're formatting the query but you aren't executing it, should you use mysql_tquery(mysql, query, "some public", "i", playerid);

And then do all the fetching inside the public?
Reply
#4

Quote:
Originally Posted by xVIP3Rx
Посмотреть сообщение
"`pid` = '%s'", playerid);"

playerid is a string ?, okay..

use "%d" for integers like playerid.
Well spoted mate. However, I'm still having an issue with the display

Quote:
Originally Posted by Denying
Посмотреть сообщение
You're formatting the query but you aren't executing it, should you use mysql_tquery(mysql, query, "some public", "i", playerid);

And then do all the fetching inside the public?
I will give that a try mate.
Reply
#5

On the dialog, use GetPlayerName, and use "%s" for it in the format.
Reply
#6

Код:
 
new area[120], damage[12], weaponz[25], shooter[MAX_PLAYER_NAME];
public DamagesQ()
{
		new fetch[256];
		cache_get_field_content(0, "area", fetch);
   		format(area, 79, "%s", fetch);
		cache_get_field_content(0, "damage", fetch);
   		format(damage, 79, "%f", fetch);
		cache_get_field_content(0, "weapon", fetch);
   		format(weaponz, 79, "%s", fetch);
		cache_get_field_content(0, "shooter", fetch);
   		format(shooter, 79, "%s", fetch);
}
stock DisplayDamages(toplayer, playerid)
{
        new playername[MAX_PLAYER_NAME], title[45];
        GetPlayerName(playerid, playername, sizeof(playername));
        format(title, sizeof(title), "%s", playername);
		format(query, sizeof(query), "SELECT * FROM `damages` WHERE `pid` = '%d'", playerid);
		mysql_function_query(dbHandle, query, true, "DamagesQ", "i", playerid);
        new dmgtxt[1000], fstr[45];
        format(fstr, sizeof(fstr), "%f damage from %s to the %s\n", damage, weaponz, area);
        strcat(dmgtxt, fstr);
		ShowPlayerDialog(toplayer, damages, DIALOG_STYLE_LIST, title, dmgtxt, "Close", "");
        return 1;
}
It only displays one damage as oppose to numerous. Any idea why?
Reply
#7

pawn Код:
new area[120], damage[12], weaponz[25], shooter[MAX_PLAYER_NAME];
forward DamagesQ(toplayer, playerid);
public DamagesQ(toplayer, playerid)
{
        new fetch[256];
        cache_get_field_content(0, "area", fetch);
        format(area, 79, "%s", fetch);
       
        cache_get_field_content(0, "damage", fetch);
        format(damage, 79, "%f", fetch);
       
        cache_get_field_content(0, "weapon", fetch);
        format(weaponz, 79, "%s", fetch);
       
        cache_get_field_content(0, "shooter", fetch);
        format(shooter, 79, "%s", fetch);
       
        new playername[MAX_PLAYER_NAME], dmgtxt[128];
        GetPlayerName(playerid, playername, sizeof(playername));
        format(dmgtxt, sizeof(dmgtxt), "%f damage from %s to the %s\n", damage, weaponz, area);
        ShowPlayerDialog(toplayer, damages, DIALOG_STYLE_LIST, playername, dmgtxt, "Close", "");
}

stock DisplayDamages(toplayer, playerid)
{

        format(query, sizeof(query), "SELECT * FROM `damages` WHERE `pid` = '%d'", playerid);
        mysql_function_query(dbHandle, query, true, "DamagesQ", "ii", toplayer, playerid);
        return 1;
}
You could use
pawn Код:
format(query, sizeof(query), "SELECT * FROM `damages` WHERE `pid` = '%d'", playerid);
        mysql_function_query(dbHandle, query, true, "DamagesQ", "ii", toplayer, playerid);
instead of the stock itself.
Reply
#8

That works too, however it only displays one entry, that being the first entry that has the Id == playerid, none other.
Reply
#9

I don't understand, it shows only one line in the dialog ? maybe because there's only one in there already ?
Reply
#10

Sorry for not being all to clear. Allow me to clarify.
There are two entries in the database relating to the players ID -


However, this is what's displayed IG.

Only one line as oppose to the two that are in the database.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)