Mysql Weapons data not loading
#1

I followed this to make it https://sampforum.blast.hk/showthread.php?tid=505081
got the storing part but it won't load.
Reply
#2

Sorry to double post but i need to ask something, how would I load the data from player or weapons ? I mean i tried the simple way and it loads the data from players but i know i make it load from players ?
Reply
#3

The table of which you are loading data from is defined in your query.
"SELECT data_fields FROM TABLE_NAME WHERE KEYWORDS"

The tutorial states:
PHP код:
SELECT weaponidammo FROM player_weapons WHERE userid = %d
Where weaponid and ammo are your fields and 'player_weapons' is the table.
Reply
#4

EIDT :-

so i tired this
pawn Код:
stock OnLoadPlayerWeapons(playerid)
{
    new
        weaponid,
        ammo,
        mysqlquery[124];
    mysql_format(g_SQL, mysqlquery, sizeof(mysqlquery), "select weaponid, ammo from weapons where name id = %d;", PlayerInfo[playerid][pID]);
    print(mysqlquery);
    mysql_pquery(g_SQL, mysqlquery);
    for(new i, j = cache_get_row_count(g_SQL); i < j; i++) // loop through all the rows that were found
    {
        weaponid    = cache_get_row_int(i, 0, g_SQL);
        ammo        = cache_get_row_int(i, 1, g_SQL);
        printf("weaponid = %d , Ammo = %d",weaponid,ammo);
       
        if(!(0 <= weaponid <= 46)) // check if weapon is valid (should be)
        {
            printf("[info] Warning: OnLoadPlayerWeapons - Unknown weaponid '%d'. Skipping.", weaponid);
            continue;
        }
       
        GivePlayerWeaponEx(playerid, weaponid, ammo);
    }
    return;
}
No use it gives me
pawn Код:
select weaponid, ammo from weapons where name id = 1; //should be fine
but nothing more.

While at my database
Reply
#5

Quote:
Originally Posted by AroseKhanNiazi
Посмотреть сообщение
Код:
select weaponid, ammo from weapons where name id = 1; //should be fine
The field of your table structure is userid. mysql logs should have warned you about that (but you probably didn't check it).

Also threaded queries are meant to retrieve the data in a public function and not directly at the place you execute the query.
Reply
#6

Okay so i really didn't remember that there are many errors
pawn Код:
mysql_format(g_SQL, query, sizeof(query), "UPDATE players SET lastattacked=%s,speedoactive=%d,speedinkilometer=%d,skill=%d,vehiclesstolen=%d,gender=%d,fightstyle=%d WHERE id = %d LIMIT 1",
        PlayerInfo[playerid][pLastAttacked],PlayerInfo[playerid][pSpeedoActive],PlayerInfo[playerid][pSpeedInKiloMeter],PlayerInfo[playerid][pSkill],PlayerInfo[playerid][pVehiclesStolen],PlayerInfo[playerid][pGender],PlayerInfo[playerid][pFightStyle],PlayerInfo[playerid][pID]);
        mysql_tquery(g_SQL, query);
for this


This error at lot of places with almost same code
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)