AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   ahh my head hurts -- amx_ca (https://forums.alliedmods.net/showthread.php?t=11524)

KaOs 03-21-2005 22:56

ahh my head hurts -- amx_ca
 
I'm trying to get my connection announcer plugin to work for hours now.. after many headaches I decided to switch to the array.inc functions instead of standard arrays.. and well now my CS just crashes when I load it..

Any idea what's wrong with my code?





addons/amxmodx/configs/ca/player_connect.cfg
Code:

"255" "255" "255"
Player is connecting!
Blah blah!
Please work!

Code:
#include <amxmodx> #include <amxmisc> #include <geoip> #include <array> new clientMessages_1 new clientMessages_2 new clientMessages_3 new messageCount_1 = 0 new messageCount_2 = 0 new messageCount_3 = 0 new messageColor_1[3] new messageColor_2[3] new messageColor_3[3] public plugin_init() {     register_plugin("AMX Connection Announcer", "1.0", "whitemike")     register_clcmd("amx_reloadca", "reloadMessages", ADMIN_KICK, " - Reload config for AMX_CA")     register_clcmd("amx_testca", "testShit", ADMIN_KICK, " - Testing shit, bitch.")     reloadMessages(0)     return PLUGIN_CONTINUE } public reloadMessages(id) {     if(id != -1) {         client_print(id, print_chat, "[AMXX] Reloading ..")     }     clientMessages_1 = new_string_list()     clientMessages_2 = new_string_list()     clientMessages_3 = new_string_list()     messageCount_1 = 0     messageCount_2 = 0     messageCount_3 = 0     messageColor_1[0] = false     messageColor_1[1] = false     messageColor_1[2] = false     messageColor_2[0] = false     messageColor_2[1] = false     messageColor_2[2] = false     messageColor_3[0] = false     messageColor_3[1] = false     messageColor_3[2] = false     loadMessages(1)     loadMessages(2)     loadMessages(3)     if(id != -1) {         client_print(id, print_chat, "[AMXX] Done. %i total.", (messageCount_1+messageCount_2+messageCount_3))     }     return PLUGIN_HANDLED } public testShit(id, level, cid) {     client_print(0, print_chat, "[AMXX] Shoulda worked bitch..")     showMessage(id, 1)     return PLUGIN_HANDLED } public client_connect(id) {     showMessage(id, 1)     return PLUGIN_CONTINUE } public client_putinserver(id) {     showMessage(id, 2)     return PLUGIN_CONTINUE } public client_disconnect(id) {     showMessage(id, 3)     return PLUGIN_CONTINUE } public showMessage(id, type) {     new thisMessage[256]     new clientMessages = new_string_list()     new messageColor[3]     new messageCount = 0     if(type == 1) {         clientMessages = clientMessages_1         messageColor = messageColor_1         messageCount = messageCount_1     }     if(type == 2) {         clientMessages = clientMessages_2         messageColor = messageColor_2         messageCount = messageCount_2     }     if(type == 3) {         clientMessages = clientMessages_3         messageColor = messageColor_3         messageCount = messageCount_3     }     // GET CLIENT INFO //     new clientName[33]     new clientID[35]     new clientIP[16]     new clientPingTmp     new clientLossTmp     new clientPing[10]     new clientLoss[10]     new clientCountry[65]     get_user_name(id, clientName, 32)     get_user_authid(id, clientID, 34)     get_user_ip(id, clientIP, 15)     get_user_ping(id, clientPingTmp, clientLossTmp)     geoip_country(clientIP, clientCountry, 64)     // END CLIENT INFO //     new tmpStr[256]     list_get_string(clientMessages, random(messageCount), tmpStr, 255)     format(thisMessage, 255, "%s", tmpStr)     format(clientPing, 9, "%i", clientPingTmp)     format(clientLoss, 9, "%i", clientLossTmp)     replace(thisMessage, 255, "$user_name$", clientName)     replace(thisMessage, 255, "$user_auth$", clientID)     replace(thisMessage, 255, "$user_ip$", clientIP)     replace(thisMessage, 255, "$user_ping$", clientPing)     replace(thisMessage, 255, "$user_loss$", clientLoss)     replace(thisMessage, 255, "$user_country$", clientCountry)     set_hudmessage(messageColor[0], messageColor[1], messageColor[2], 0.2, 0.6, 2, 6.0, 12.0, 0.1, 0.2, 2)     show_hudmessage(0, thisMessage)     return PLUGIN_HANDLED } public loadMessages(type) {     new fileName[18]     new filePath[64]     if(type == 1) fileName = "player_connect"     if(type == 2) fileName = "player_join"     if(type == 3) fileName = "player_disconnect"     get_configsdir(filePath, 63)     format(filePath, 63, "%s/ca/%s.cfg", filePath, fileName)     if(!file_exists(filePath)) {         client_print(0, print_chat, "[AMXX] AMX Connection Announcer: File Not Found: '%s' -- Quitting..", filePath)         log_amx("[AMXX] AMX Connection Announcer: File Not Found: '%s' -- Quitting..", filePath)         return PLUGIN_HANDLED     }     new fileLine = 0, fileLLen     new fileLData[256]     new msgsLoaded = 0     new msgColor[3]     new tmpList = new_string_list()             while(read_file(filePath,fileLine++,fileLData,255,fileLLen)) {         if(!equal(fileLData, "//", 2) && !equal(fileLData, ";", 1) && strlen(fileLData) > 0) {             if(fileLine == 0) {                 parse(fileLData, msgColor[0], 3, msgColor[1], 3, msgColor[2], 3)             }             else {                 list_store_string(tmpList, msgsLoaded, fileLData)                 msgsLoaded++             }         }     }     if(type == 1){         clientMessages_1 = tmpList         messageCount_1 = msgsLoaded         messageColor_1 = msgColor     }     if(type == 2){         clientMessages_2 = tmpList         messageCount_2 = msgsLoaded         messageColor_2 = msgColor     }     if(type == 3){         clientMessages_3 = tmpList         messageCount_3 = msgsLoaded         messageColor_3 = msgColor     }     return PLUGIN_HANDLED }

KaOs 03-21-2005 23:00

I tried again and it no longer crashes, but it does print "dne" .. and theres not even a 'D' in the player_connect.cfg file lol

Ingram 05-18-2005 19:12

this is an old post, but i was wondering if u had any insight on the crashes. My server crashes (the array dll is responsible) when i have new_string_list() in the init and i change the map. (only the first map load works)

also, i believe dne is a blank or error in a string


All times are GMT -4. The time now is 09:49.

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