Raised This Month: $ Target: $400
 0% 

A few questions about pawn...


Post New Thread Reply   
 
Thread Tools Display Modes
MaximusBrood
Veteran Member
Join Date: Sep 2005
Location: The Netherlands
Old 12-08-2005 , 13:28  
Reply With Quote #11

Quote:
Originally Posted by DotNetJunkie
Quote:
Originally Posted by mysticssjgoku4
Yes that is true, I've ran into many times. A single line can lead many more errors, the end result is the first error listed.
yeah, this is one of the damn problems with C/C++ (and similar languages)
that makes it hard to debug, the compiler may trigger tens and
even hundreds of errors when the cause is only coming from like
1 or 2 lines.
Thats why you always have to start at debugging the first error
__________________
Released six formerly private plugins. Not active here since ages.
MaximusBrood is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 10-30-2007 , 11:43   Re: A few questions about pawn...
Reply With Quote #12

Not trying to jack the thread or anything but can someone show me how to declare and add elements to a dynamic array?
__________________
Bugsy is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 10-30-2007 , 12:14   Re: A few questions about pawn...
Reply With Quote #13

Have a look in amxx1.8 plmenu's plugin_init()
ConnorMcLeod is offline
Dygear
SourceMod Donor
Join Date: Apr 2004
Location: Levittown, NY
Old 12-30-2009 , 05:57   Re: A few questions about pawn...
Reply With Quote #14

Quote:
Originally Posted by Bugsy View Post
Not trying to jack the thread or anything but can someone show me how to declare and add elements to a dynamic array?
Quote:
Originally Posted by ConnorMcLeod View Post
Have a look in amxx1.8 plmenu's plugin_init()
I was searching for Dynamic Length Arrays, and I stumbled across this and ArrayX's various threads but this one was the only thing that seemed to offer a 'native' solution.

So I was off to find out where the functions come from. Are they build in PAWN functions that I've missed in my absence? I see the array declaration on line 60 and 61:

Code:
new Array:g_bantimes;
new Array:g_slapsettings;
Followed by some functions that don't seem to be within the AMX Mod include files. For example, found within the plugin_init function on lines 107 & 123 you find these:

Code:
	g_bantimes = ArrayCreate();
	// Load up the old default values
	ArrayPushCell(g_bantimes, 0);
	ArrayPushCell(g_bantimes, 5);
	ArrayPushCell(g_bantimes, 10);
	ArrayPushCell(g_bantimes, 15);
	ArrayPushCell(g_bantimes, 30);
	ArrayPushCell(g_bantimes, 45);
	ArrayPushCell(g_bantimes, 60);
	
	
	g_slapsettings = ArrayCreate();
	// Old default values
	ArrayPushCell(g_slapsettings, 0); // First option is ignored - it is slay
	ArrayPushCell(g_slapsettings, 0); // slap 0 damage
	ArrayPushCell(g_slapsettings, 1);
	ArrayPushCell(g_slapsettings, 5);
.

I can't find any instance of these functions within AMX Mod X's source code. I've searched (ArrayCreate, ArrayClear, ArrayPushCell & ArrayGetCell) So I'm wondering where I could go about find documentation on these functions.
__________________
Dygear is offline
Send a message via AIM to Dygear Send a message via MSN to Dygear Send a message via Skype™ to Dygear
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 12-30-2009 , 07:01   Re: A few questions about pawn...
Reply With Quote #15

The funcwiki is not up-to-date.

Look directly into the includes in your includes/ directory. See so cellarray.inc.
__________________
Arkshine is offline
Dygear
SourceMod Donor
Join Date: Apr 2004
Location: Levittown, NY
Old 12-30-2009 , 07:39   Re: A few questions about pawn...
Reply With Quote #16

Quote:
Originally Posted by Arkshine View Post
The funcwiki is not up-to-date.

Look directly into the includes in your includes/ directory. See so cellarray.inc.
Yeah, I just found that. Thanks mate for the redirect. I've been playing around with the ArrayString functions, for reading strings from a file, and pushing them onto an a dynamically sized array. I'm having some trouble with this. Can you by chance offer any example code?

[Max Len of Username = 32 Characters]

I decided as a exercise that I would use a persistent note system. A plugin that would allow admins to pass notes to each other, like that found on the vB forum admin interface. Just general little notes, but notes that will stay there, even should the server crash. The skeleton of the plugin can be found below. I hope to add on it from the examples you give, and I hope that will give everyone a better understanding of the cellarray functions.

Code:
/******************************************************************************** * Plugin name: Admin Notes. * Made by: Dygear * Modules required: Cell Array, AMX Mod X, AMX Misc & File. * Warranties : This file is provided as is (no warranties). ********************************************************************************/ #include <amxmodx> #include <amxmisc> #define MAX_NOTE_SIZE 81 #define MAX_NOTE_LINE (MAX_NOTE_SIZE - 1) #define FILE_NOTE_NAME "notes.txt" new Array:file; public plugin_init() {     register_plugin("Admin Notes", "0.1", "Dygear");     register_concmd("amx_note_read", "readFile", ADMIN_ADMIN, "- Print Note List");     register_concmd("amx_note_add", "addLine", ADMIN_ADMIN, "^"<note>^"");     register_concmd("amx_note_rm", "rmLine", ADMIN_ADMIN, "<line#>");     file = ArrayCreate(); } /* amx_note_read */ public readFile(id, level, cid) {     if (!cmd_access(id, level, cid, 1))         return PLUGIN_HANDLED;     /* Read the file & Print the Array to Console. */     // Get File Name     new path[256];     get_configsdir(path, 255);     add(path, 255, FILE_NOTE_NAME);     // Read each line from file & Place in Array     if (file_exists(path) == 1) {         new line = 0, text[MAX_NOTE_SIZE], len = MAX_NOTE_LINE, txtLen = MAX_NOTE_LINE;         while (read_file(path, line, text, len, txtLen) != 0)             ArrayPushString(file, text);     }     return PLUGIN_CONTINUE; } /* amx_note_add "<note>" */ public addLine(id, level, cid) {     if (!cmd_access(id, level, cid, 1))         return PLUGIN_HANDLED;     // Add a Line to the Array & File.     new note[MAX_NOTE_SIZE];     read_argv(1, note, MAX_NOTE_LINE);     return PLUGIN_CONTINUE; } /* amx_note_rm "<line#>" */ public rmLine(id, level, cid) {     if (!cmd_access(id, level, cid, 1))         return PLUGIN_HANDLED;         // Removes a Line frm the Array & File.     return PLUGIN_CONTINUE; }
__________________

Last edited by Dygear; 01-03-2010 at 16:15.
Dygear is offline
Send a message via AIM to Dygear Send a message via MSN to Dygear Send a message via Skype™ to Dygear
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 17:37.


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