AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   it appears that my function should work... (https://forums.alliedmods.net/showthread.php?t=6468)

TotalNoobScripter 10-03-2004 11:34

it appears that my function should work...
 
can any one tell me the bug(s) of my noob script. It suppose to change the varaibles you see then in a mysql database. The function is called by a menu with jobchange(id,"Bellboy", "6");. the mysql database has a job column that corresponds with an authid colum.

Code:
public jobchange(id,newjob[],sal[]){     new authid[32],query[256];     get_user_authid(id,authid,31);     format(query,255,"UPDATE money SET job=%s,WHERE steamid='%s'",newjob,authid);     mysql_query(mysql,query);     format(query,255,"UPDATE money SET salary=%s,WHERE steamid='%s'",sal,authid);     mysql_query(mysql,query);     server_cmd("amx_csay User %s's job info has been changed",authid);         return PLUGIN_HANDLED; }

xeroblood 10-03-2004 11:39

In SQL, strings must be enclosed in single quotes.. You have done this for SteamID, but not for Job... Also, you have an extra comma in there, syntax error..

Change:
Code:

UPDATE money SET job=%s,WHERE steamid='%s'
To:
Code:

UPDATE money SET job='%s' WHERE steamid='%s'

Also, you could combine both of your queries into:
Code:
UPDATE money SET job='%s', salary='%s' WHERE steamid='%s'

Maybe that helps!!

TotalNoobScripter 10-03-2004 12:05

nothin
 
ok i expanded my plugin to this....

Code:
public jobchange(id,newjob[],sal[]){     new authid[32],query[256],numoldbal[32];     get_user_authid(id,authid,31);     format(query,255,"SELECT balance FROM money WHERE steamid='%s'",authid);     mysql_query(mysql,query);     mysql_getfield(mysql,1,"numoldbal",31);     oldbal = str_to_num(numoldbal);     if(oldbal > 250) {     format(query,255,"UPDATE money SET balance=balance-250 WHERE steamid='%s'",authid);     mysql_query(mysql,query);     client_print(id,print_chat,"[-Snort-] You Have Been Charged a $250 Employment Fee.");     format(query,255,"UPDATE money SET job='%s', salary='%s' WHERE steamid='%s'",newjob,sal,authid);     mysql_query(mysql,query);     client_print(id,print_chat,"Your Job Has Been Changed",authid);     return PLUGIN_HANDLED;     } else {         client_print(id,print_chat,"[-Snort-] You Don't Have The Money To Pay The $250 Employment Fee");         return PLUGIN_HANDLED;         } }

The problem is IT KEEPS SAYING THAT U DONT HAVE $250 WHEN U DO!
someone plz help! plz plz plz plz plz plz plz plz plz plz


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

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