Raised This Month: $ Target: $400
 0% 

Plugin does nothing


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
neo-the-hacker
New Member
Join Date: Apr 2006
Old 04-05-2006 , 10:58   Plugin does nothing
Reply With Quote #1

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
neo-the-hacker is offline
Send a message via ICQ to neo-the-hacker
Xanimos
Veteran Member
Join Date: Apr 2005
Location: Florida
Old 04-05-2006 , 21:56  
Reply With Quote #2

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.
Xanimos is offline
Send a message via AIM to Xanimos Send a message via MSN to Xanimos
Twilight Suzuka
bad
Join Date: Jul 2004
Location: CS lab
Old 04-05-2006 , 22:10  
Reply With Quote #3

variable = "string" is fine, though you have to be careful not to overrun the buffer.
__________________
Twilight Suzuka is offline
Send a message via AIM to Twilight Suzuka Send a message via MSN to Twilight Suzuka
neo-the-hacker
New Member
Join Date: Apr 2006
Old 04-07-2006 , 11:54  
Reply With Quote #4

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
neo-the-hacker is offline
Send a message via ICQ to neo-the-hacker
Xanimos
Veteran Member
Join Date: Apr 2005
Location: Florida
Old 04-07-2006 , 14:13  
Reply With Quote #5

Where do you see what is in the database? Maybe your reading it out wrong.
Xanimos is offline
Send a message via AIM to Xanimos Send a message via MSN to Xanimos
neo-the-hacker
New Member
Join Date: Apr 2006
Old 04-07-2006 , 18:21  
Reply With Quote #6

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.
neo-the-hacker is offline
Send a message via ICQ to neo-the-hacker
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


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


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