Raised This Month: $ Target: $400
 0% 

Whats wrong with my code?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
#8 SickneSS
BANNED
Join Date: Sep 2008
Location: Here
Old 08-08-2010 , 09:20   Whats wrong with my code?
Reply With Quote #1

Look,Im not to good at all in this,but I made what I can,when I use say /maps on chat my server crash without errors.So I need some help on this,(I Made this code based on bot apology for tk by fysiks)

Code...
PHP Code:
/* Plugin generated by AMXX-Studio */

#include <amxmodx>
#include <amxmisc>

#define PLUGIN "New Plug-In"
#define VERSION "1.0"
#define AUTHOR "#8 SickneSS"

#define MAXMAPS        20

new Maps[MAXMAPS][32]

public 
plugin_init() {
    
register_plugin(PLUGINVERSIONAUTHOR)
    
    
register_clcmd("say /maps","MapsMenu",ADMIN_MAP)
}

public 
MapsMenu(id,level,cid
{
    if(!
cmd_access(id,level,cid,1))
        return 
PLUGIN_HANDLED
        
    
new Menu menu_create("\r[Mix Maker]\y Maps Menu :","MapsMenu_Handler")
    
    new 
Mapname[32]
    new 
Item[MAXMAPS]
    
    new 
MapFile[64]
    
get_configsdir(MapFile,63)
    
add(MapFile,63,"/mapsmenu.ini")
    
    new 
Num
    
if(!file_exists(MapFile))
        
client_cmd(id,"amx_mapmenu")
    else
    {
        new 
fopen(MapFile,"rt")
    
        for(new 
0;MAXMAPS;i++)
        {
            while(!
feof(f))
            {
                
fgets(f,Mapname,31)
                
                if(!
Mapname[0] || Mapname[0] == ';'
                
|| Mapname[0] == '/' && Mapname[1] == '/') continue;
                         
                
trim(Mapname)
                
strtolower(Mapname)
            
                
Num++
                
num_to_str(Num,Item,MAXMAPS)
            
                
copy(Maps[i][MAXMAPS],31,Item)
                
menu_additem(Menu,Mapname,Item)    
            }
            
fclose(f)
        }

    }

    
menu_display(id,Menu)
    return 
PLUGIN_HANDLED
}

public 
MapsMenu_Handler(id,Menu,item)
{
    if(
item == MENU_EXIT)
    {
        
menu_destroy(Menu)
        return 
PLUGIN_HANDLED
    
}
    
    new 
iData[6]
    new 
iName[64]
    new 
Access
    
new Callback
    menu_item_getinfo
(Menu,item,Access,iData,5,iName,63,Callback)
    
    new 
Map str_to_num(iData)
    
    if(
Map)
        
client_cmd(id,"amx_on;amx_map %s",iName)
        
    return 
PLUGIN_HANDLED

#8 SickneSS is offline
Send a message via MSN to #8 SickneSS Send a message via Skype™ to #8 SickneSS
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 08-08-2010 , 10:45   Re: Whats wrong with my code?
Reply With Quote #2

Code:
for(new i = 0;i < MAXMAPS;i++)
{
       while(!feof(f))
       {
Do you understand what are you doing there ?
__________________
Arkshine is offline
#8 SickneSS
BANNED
Join Date: Sep 2008
Location: Here
Old 08-08-2010 , 10:48   Re: Whats wrong with my code?
Reply With Quote #3

Quote:
Originally Posted by Arkshine View Post
Code:
for(new i = 0;i < MAXMAPS;i++)
{
       while(!feof(f))
       {
Do you understand what are you doing there ?
Yes,why? What is wrong there?
#8 SickneSS is offline
Send a message via MSN to #8 SickneSS Send a message via Skype™ to #8 SickneSS
Alucard^
AMXX Moderator: Others
Join Date: Sep 2007
Location: Street
Old 08-08-2010 , 11:13   Re: Whats wrong with my code?
Reply With Quote #4

That part is wrong... you should delete the first loop, use only the while part and add a condition for the MAXMAPS thing, inside... something like:

if(Num == MAXMAPS) break;
__________________
Approved Plugins - Steam Profile

Public non-terminated projects:
All Admins Menu, HLTV parameters, Subnick,
Second Password (cool style), InfoZone,
Binary C4 plant/defuse, and more...

Private projects:
NoSpec (+menu), NV Surf Management,
PM Adanved System, KZ longjump2, and more...
Alucard^ is offline
Send a message via Skype™ to Alucard^
#8 SickneSS
BANNED
Join Date: Sep 2008
Location: Here
Old 08-08-2010 , 16:40   Re: Whats wrong with my code?
Reply With Quote #5

Quote:
Originally Posted by Alucard^ View Post
That part is wrong... you should delete the first loop, use only the while part and add a condition for the MAXMAPS thing, inside... something like:

if(Num == MAXMAPS) break;
Ok I wil try that,not now,because Im tired ...
#8 SickneSS is offline
Send a message via MSN to #8 SickneSS Send a message via Skype™ to #8 SickneSS
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 14:38.


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