AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Pissing me off....TS Weapon Crap (https://forums.alliedmods.net/showthread.php?t=16868)

mysticssjgoku4 08-21-2005 15:51

Pissing me off....TS Weapon Crap
 
Ok, I've been working on this for a long time, and this is pissing me off.
I keep executing the savegun feature, and it shows me this in the console.

Code:


WeaponID: 4, Clip: 7, Ammo: 60, Mode: 3, Extra: <

wtf? Extra should be 1, 2, 4, 8 not that crap.
Would anyone know why this is happening?

THanks.

Code:
////////////////////////////////////////////// //-------------------------------------------- //-Weapon Remember---Remo Williams------------ //-------------------------------------------- //////////////////////////////////////////////// #include <amxmodx> #include <amxmisc> #include <dbi> #include <engine> #include <fun> #include <tsx> new Sql:dbc new Result:result // Start of plugin public plugin_init() {     register_plugin("Weapon Checker","1.0","Remo Williams")     register_concmd("amx_savegun","check_weapons",ADMIN_IMMUNITY," - Saves Guns in TS")     register_concmd("amx_savegun2","check_w",ADMIN_IMMUNITY," - Saves Guns in TS")     register_concmd("amx_returngun","return_weapons",ADMIN_IMMUNITY," - Returns Guns in TS")     register_cvar("weapon_save_host","localhost")     register_cvar("weapon_save_user","root")     register_cvar("weapon_save_pass","")     register_cvar("weapon_save_db","economy")     set_task(1.0,"start_sql")     set_task(10.0, "check_weapons", _, _, _, "b", 1) } //Create a connection (BY Harbu public start_sql() {     new host[32], username[32], password[32], dbname[32], error[32]     get_cvar_string("weapon_save_host",host,32)     get_cvar_string("weapon_save_user",username,32)     get_cvar_string("weapon_save_pass",password,32)     get_cvar_string("weapon_save_db",dbname,32)     dbc = dbi_connect(host,username,password,dbname,error,32)     if (dbc == SQL_FAILED)         {         server_print("[WeaponSave] Could Not Connect To SQL Database^n")     }     else         {         server_print("[WeaponSave] Connected To SQL, Have A Nice Day!^n")     } } public check_weapons(id) {     new ammo, clip, mode, extra, authid[32], name[32]     get_user_authid(id,authid,sizeof(authid))     get_user_name(id, name, 31)     new gunid = ts_getuserwpn(id, ammo, clip, mode, extra)     if(!is_user_connected(id)) {         return PLUGIN_HANDLED     }     if(clip >= 1) {         get_user_authid(id, authid, 31)         dbi_query(Sql:dbc,"INSERT INTO plr_weapons (SteamID, gunid, ammo, clip, mode, extra) VALUES('%s','%i','%i','%i','%i','%i')", authid, gunid, clip, ammo, mode, extra)         console_print(id, "WeaponID: %i, Clip: %d, Ammo: %d, Mode: %d, Extra: %s", gunid, ammo, clip, mode, extra)         return PLUGIN_HANDLED     }     console_print(id,"Gun Not Detected! For Player: %s", name)     return PLUGIN_HANDLED } public client_spawn(id) {     return_weapons(id) } public return_weapons(id) {     new query[256], playername[33], authid[32]     get_user_authid( id, authid, 31)     get_user_name( id, playername, sizeof(playername))     if(!is_user_connected(id)) {         return PLUGIN_HANDLED     }     format( query, 255, "SELECT gunid,ammo,clip,extra FROM plr_weapons WHERE steamid='%s'", authid)     result = dbi_query( dbc, query)     new GunID, Ammo, Clip, Extra     if( dbi_nextrow( result ) > 0 ) {         GunID = dbi_field(result,1)         Ammo = dbi_field(result,2)         Clip = dbi_field(result,3)         Extra = dbi_field(result,4)         dbi_free_result(result)                 ts_giveweapon(id,GunID,Ammo,Extra)         client_print(id,print_console,"ID: %s, GunID: %i, AMMO: %i, CLIP: %i,EXTRA: %i",authid,GunID,Ammo,Clip,Extra)             }     return PLUGIN_HANDLED }

XxAvalanchexX 08-21-2005 15:55

It might actually return some crazy bit-code. See if displaying it with %d differs from %i.

mysticssjgoku4 08-21-2005 20:59

Ok, thanks, Someone only notified me of only two variables, S for string, and I for integer.
BUT, it doesn't insert it into the sql. The names are correct....does it matter if the column is varchar?

XxAvalanchexX 08-21-2005 21:07

%s is string, %i is integer, %f is float, %L is language (AMXx specific I believe), and %d is simply "data", which should be capable of displaying any type of data.

mysticssjgoku4 08-21-2005 22:19

Quote:

Originally Posted by XxAvalanchexX
%s is string, %i is integer, %f is float, %L is language (AMXx specific I believe), and %d is simply "data", which should be capable of displaying any type of data.

Alright, thanks, but it isn't inserting it into the sql.

XxAvalanchexX 08-21-2005 23:01

Great, but I thought your problem was the "extra" variable -- have you tried displaying it with %d and seeing if the output is different?

mysticssjgoku4 08-22-2005 01:18

Quote:

Originally Posted by XxAvalanchexX
Great, but I thought your problem was the "extra" variable -- have you tried displaying it with %d and seeing if the output is different?

I'm using %d for the output, it echo's it back right, but now it isn't inserting anything into the sql. It was inserting the other information in there before I added the gunid variable.....any suggestions?

Thank You, Man.

---
Update: Here's the current script I'm Using:

Code:
////////////////////////////////////////////// //-------------------------------------------- //-Weapon Remember---Remo Williams------------ //-------------------------------------------- //////////////////////////////////////////////// #include <amxmodx> #include <amxmisc> #include <dbi> #include <engine> #include <fun> #include <tsx> new Sql:dbc new Result:result // Start of plugin public plugin_init() {     register_plugin("Weapon Checker","1.0","Remo Williams")     register_concmd("amx_savegun","check_weapons",ADMIN_IMMUNITY," - Saves Guns in TS")     register_concmd("amx_savegun2","check_w",ADMIN_IMMUNITY," - Saves Guns in TS")     register_concmd("amx_returngun","return_weapons",ADMIN_IMMUNITY," - Returns Guns in TS")     register_cvar("weapon_save_host","localhost")     register_cvar("weapon_save_user","root")     register_cvar("weapon_save_pass","")     register_cvar("weapon_save_db","economy")     set_task(1.0,"start_sql")     set_task(10.0, "check_weapons", _, _, _, "b", 1) } //Create a connection (BY Harbu public start_sql() {     new host[32], username[32], password[32], dbname[32], error[32]     get_cvar_string("weapon_save_host",host,32)     get_cvar_string("weapon_save_user",username,32)     get_cvar_string("weapon_save_pass",password,32)     get_cvar_string("weapon_save_db",dbname,32)     dbc = dbi_connect(host,username,password,dbname,error,32)     if (dbc == SQL_FAILED)         {         server_print("[WeaponSave] Could Not Connect To SQL Database^n")     }     else         {         server_print("[WeaponSave] Connected To SQL, Have A Nice Day!^n")     } } public check_weapons(id) {     new ammo, clip, mode, extra, authid[32], name[32]     get_user_authid(id,authid,sizeof(authid))     get_user_name(id, name, 31)     new gunid = ts_getuserwpn(id, ammo, clip, mode, extra)     if(!is_user_connected(id)) {         return PLUGIN_HANDLED     }     if(clip >= 1) {         get_user_authid(id, authid, 31)         dbi_query(Sql:dbc,"INSERT INTO plr_weapons (SteamID, gunid, ammo, clip, mode, extra) VALUES('%s','%d','%i','%i','%i','%d')", authid, gunid, clip, ammo, mode, extra)         console_print(id, "WeaponID: %i, Clip: %d, Ammo: %d, Mode: %d, Extra: %d", gunid, ammo, clip, mode, extra)         return PLUGIN_HANDLED     }     console_print(id,"Gun Not Detected! For Player: %s", name)     return PLUGIN_HANDLED } public client_spawn(id) {     return_weapons(id) } public return_weapons(id) {     new query[256], playername[33], authid[32]     get_user_authid( id, authid, 31)     get_user_name( id, playername, sizeof(playername))     if(!is_user_connected(id)) {         return PLUGIN_HANDLED     }     format( query, 255, "SELECT gunid,ammo,clip,extra FROM plr_weapons WHERE steamid='%s'", authid)     result = dbi_query( dbc, query)     new GunID, Ammo, Clip, Extra     if( dbi_nextrow( result ) > 0 ) {         GunID = dbi_field(result,1)         Ammo = dbi_field(result,2)         Clip = dbi_field(result,3)         Extra = dbi_field(result,4)         dbi_free_result(result)                 ts_giveweapon(id,GunID,Ammo,Extra)         client_print(id,print_console,"ID: %s, GunID: %i, AMMO: %i, CLIP: %i,EXTRA: %i",authid,GunID,Ammo,Clip,Extra)             }     return PLUGIN_HANDLED }

mysticssjgoku4 08-22-2005 08:50

*Bump*

Twilight Suzuka 08-22-2005 14:21

Stop using SQL for such a stupid little thing?

mysticssjgoku4 08-22-2005 17:53

Quote:

Originally Posted by Twilight Suzuka
Stop using SQL for such a stupid little thing?

Don't post unless you're going to help? KthnxBai.
The plugin is designed to save the players weapons in which they EARNED THE MONEY FOR TO BUY!!! OMG THAT IS SO STUPID!
Please now. It would be nice if someone would assist me. Thanks.

----

I got it fixed. I found out, it wasn't connecting to the db. One of the commands at top wasn't attached to anything, and the compiler failed to give me an error. Fixed.


All times are GMT -4. The time now is 14:17.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.