safra36 / PlayerSkin

A simple playerskin manager plugin with useful features
20 stars 5 forks source link

Database error both sqlite and mysql #31

Open majsteeer opened 1 year ago

majsteeer commented 1 year ago

I am currently using this plugin with mysql database but sqlite is also not working and server console throws this error

L 11/21/2022 - 18:37:33: [SM] Exception reported: Current result set has no fetched rows L 11/21/2022 - 18:37:33: [SM] Blaming: PlayerSkin.smx L 11/21/2022 - 18:37:33: [SM] Call stack trace: L 11/21/2022 - 18:37:33: [SM] [0] SQL_FetchString L 11/21/2022 - 18:37:33: [SM] [1] Line 1594, F:_MyFiles\Sourcemod\Files\WorkingOn\Project\PlayerSkins_Git\PlayerSkin\scripting\PlayerSkin.sp::IsUserWithSkins L 11/21/2022 - 18:37:33: [SM] [2] Line 135, F:_MyFiles\Sourcemod\Files\WorkingOn\Project\PlayerSkins_Git\PlayerSkin\scripting\PlayerSkin.sp::PlayerSpawn L 11/21/2022 - 18:37:41: [SM] Exception reported: Current result set has no fetched rows L 11/21/2022 - 18:37:41: [SM] Blaming: PlayerSkin.smx L 11/21/2022 - 18:37:41: [SM] Call stack trace: L 11/21/2022 - 18:37:41: [SM] [0] SQL_FetchString L 11/21/2022 - 18:37:41: [SM] [1] Line 1594, F:_MyFiles\Sourcemod\Files\WorkingOn\Project\PlayerSkins_Git\PlayerSkin\scripting\PlayerSkin.sp::IsUserWithSkins L 11/21/2022 - 18:37:41: [SM] [2] Line 135, F:_MyFiles\Sourcemod\Files\WorkingOn\Project\PlayerSkins_Git\PlayerSkin\scripting\PlayerSkin.sp::PlayerSpawn

seems like it may be related to this because i cant find anything else that could cause problem Format(Query, sizeof(Query), "SELECT ct_skin, ct_arm FROM userskins WHERE id = '%s'", SteamAuth);

but when i execute this on database server with %s changed to my steamid64 it correctly gives a result.

Same thing happens when i try to use this plugin on server when i have %s changed to my steamid64

Maybe it is worth to mention that this plugin is not creating any indexes in database when other plugins are creating them.

eehs commented 1 year ago

The query itself that SELECTs a user's player skin and arms is correct as you pointed out. But there exists a couple functions alongside IsUserWithSkins in the source that performs a SQL_FetchString() without first fetching a row from the current result set.

By fetching a row before the string and recompiling should fix this issue.

E.g

if (SQL_FetchRow(hQuery)) {
    SQL_FetchString(hQuery, 0, SkinsPath, sizeof(SkinsPath));      
    SQL_FetchString(hQuery, 1, ArmsPath, sizeof(ArmsPath));     
    ... 
}