AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Plugin does nothing (https://forums.alliedmods.net/showthread.php?t=26600)

neo-the-hacker 04-05-2006 10:58

Plugin does nothing
 
Hi
I've just begun to skript with amx. I have a Problem with my first Plugin:
It does nothing. Amxx say that it ios loaded and it does not show any errors.
It writes nothing to the logfile or the console, but it should print something when it has been loaded(log_amx).
Code:
#include <amxmodx> #include <dbi> new Sql:dbc new Result:result public plugin_init() {     register_plugin("admincall","0.1","neo-networks")     register_concmd("calladmin", "camenu",-1,"Ruft einen Admin")     register_menucmd(register_menuid("\yCall Admin:"), 1023, "calladmin")     set_task(Float:10.0,"sql_init")     log_amx("[CA Menu] geladen") } public sql_init() {     new host[64], username[32], password[32], dbname[32], error[32]     host="***.***.***.***"     username="******"     password="*******"     dbname="******"     log_amx("[CA Menu] SQL Init")     dbc = dbi_connect(host,username,password,dbname,error,32)     if (dbc == SQL_FAILED)         log_amx("[AMXX] SQL Connection Failed")     else         dbi_query(dbc,"CREATE TABLE IF NOT EXISTS `calladmins` (`Nickname` text NOT NULL,`server` text NOT NULL,`admin` text NOT NULL,`grund` text NOT NULL,  `datum` text NOT NULL) TYPE=MyISAM;") } public calladmin(id,key) {    log_amx("[CA Menu] CallAdmin")     if (dbc == SQL_FAILED)    return PLUGIN_HANDLED     new arg[32]     if (read_argc() == 0) return PLUGIN_HANDLED    switch(key) {       case 0: {          arg="Cheater"       }       case 1: {          arg="Bot"       }       case 2: {          arg="Mapchange"       }       case 3: {          arg="Sonstiges"       }    }     new ServerName[80]           new name[80]     new zeit[21]     get_user_info(id, "name", name, 31)     get_cvar_string("server_name", ServerName, 20)     get_time("%d.%m.%Y - %H:%M:%S",zeit,21)     result = dbi_query(dbc,"INSERT INTO calladmins (nickname,server,grund,datum) VALUES ( '%s','%s','%s','%s' )",name,ServerName,arg,zeit)     if (result == RESULT_OK) dbi_free_result(result)     if (result == RESULT_FAILED) return PLUGIN_HANDLED     new dbitype[32]     dbi_type(dbitype,32)     console_print(id,"Ein Admin wurde verstaendigt")     return PLUGIN_HANDLED } public camenu(id) {    log_amx("[CA Menu] Ca Menu angezeigt")    console_print(id,"CAMenu")    new menu[256]         format(menu, 255, "\yCall Admins:^n^n\w1. Cheater auf dem Server^n2. Probleme mit Bots^n3. Mapchange PLZ^n4. Anderes Problem^n^n\w0. Exit")         show_menu(id, ((1<<0|1<<1|1<<2|1<<3|1<<9)), menu)         return PLUGIN_HANDLED }
Can you find the error?

THX



Neo

Xanimos 04-05-2006 21:56

I won't fix it but I will help you along.

First, dont use variable = "string". you must use format, copy, or any string function for that.

Second, change set_task(Float:10.0,.... to set_task(10.0,.... if you are supplying a floating point number you don't use the Float:

Third, using if (read_argc() == 0) return PLUGIN_HANDLED in the menu call back will always return. There aren't arguments in that function call.

Twilight Suzuka 04-05-2006 22:10

variable = "string" is fine, though you have to be careful not to overrun the buffer.

neo-the-hacker 04-07-2006 11:54

I have solved the problem, but now there is a new one:
Code:
public PressedCalladmin(id, key) {     log_amx("[CA Menu] CallAdmin")     if (dbc == SQL_FAILED)    return PLUGIN_HANDLED     new argu[20]     new servername[200]              new name[32]          new zeit[21]     get_cvar_string("hostname",servername,100)     get_user_name(id,name,31)     get_time("%d.%m.%Y - %H:%M:%S",zeit,21)     switch(key) {         case 0: {             copy(argu,19,"Cheater")         }         case 1: {             copy(argu,19,"Bot")         }         case 2: {             copy(argu,19,"Mapchange")         }         case 3: {             copy(argu,19,"Sonstiges")         }         case 9: {             return PLUGIN_HANDLED         }     }     result = dbi_query(dbc,"INSERT INTO calladmins (nickname,server,grund,datum) VALUES ( '%s','%s','%s','%s' )",name,servername,argu,zeit)     set_hudmessage(255, 0, 0, -1.0, 0.00, 0, 6.0, 12.0)     show_hudmessage(id, "Die Anfrage wurde gesendet:  SteamID: %s <> Grund: %s <> Server: %s <> Datum: %s",name,argu,servername,zeit)       if (result == RESULT_OK) dbi_free_result(result)     if (result == RESULT_FAILED) return PLUGIN_HANDLED     new dbitype[32]     dbi_type(dbitype,32)     console_print(id,"Ein Admin wurde verstaendigt")     return PLUGIN_HANDLED }
The var name is always empty... but all other var's are filled with the right value and the skript writes the text("Ein Admin wurde verstaendigt") on the client's console

Xanimos 04-07-2006 14:13

Where do you see what is in the database? Maybe your reading it out wrong.

neo-the-hacker 04-07-2006 18:21

I don't read anything out of it. I Just write some values into it. A VB Programm reads the data and tells me in real time if somebody is needing an admin. He saves all the values, but not the name. I think the id is right, because he displays the hudmessage.


All times are GMT -4. The time now is 16:33.

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