Raised This Month: $ Target: $400
 0% 

how to set one id


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Porta0123
Member
Join Date: Apr 2014
Location: Spain
Old 07-06-2014 , 10:19   how to set one id
Reply With Quote #1

hi, i have one problem...

i have this:
Code:
new Cname[33] //class name new Cdesc[33] //class description new Cexpe[33] //class xp new Cvida[33] //clas live new Cchal[33] //class armour
and i every one need have one id, the id of this class

in =
Code:
public native_register_class(const class_name[],const class_desc[],const xp,const live,const armour) {  //here set the id of the class and save in a new "Cid"(class id) and the Cname[Cid] (Cname of the class id) etc... }

and i have the problem of the ID of the class and the problem in Cname[Cid] = class_name

i want to do this =
Cname[Cid][] = "here the text of class_name in the native"

Last edited by Porta0123; 07-06-2014 at 10:20.
Porta0123 is offline
Black Rose
Veteran Member
Join Date: Feb 2011
Location: Stockholm, Sweden
Old 07-06-2014 , 10:47   Re: how to set one id
Reply With Quote #2

Either you hardcode it.
Code:
#define MAX_CLASSES 5 new Cname[MAX_CLASSES][33] //class name copy(Cname[Cid], sizeof Cname[] - 1, class_name);

Or you look into dynamic arrays.
__________________
Black Rose is offline
Bos93
Veteran Member
Join Date: Jul 2010
Old 07-06-2014 , 15:58   Re: how to set one id
Reply With Quote #3

For strings, use param_convert

PHP Code:
public native_register_class(const class_name[],const class_desc[],const xp,const live,const armour)
{
    
param_convert);    
    
param_convert);    
    
param_convert);    
    
    
Cname class_name;
    
etc..

__________________
Bos93 is offline
Send a message via ICQ to Bos93 Send a message via Skype™ to Bos93
Porta0123
Member
Join Date: Apr 2014
Location: Spain
Old 07-06-2014 , 16:47   Re: how to set one id
Reply With Quote #4

eh...

Code:
#define MAX_CLASSES 50 new Cid new Cname[MAX_CLASSES][33] new Cdesc[MAX_CLASSES][33] new Cexpe[33] new Cvida[33] new Cchal[33] public native_neo_register_class(const clase_name[], const clase_descripcion[],clase_experiencia,clase_vida, clase_chaleco) {     copy(Cname[Cid],sizeof Cname[] - 1,clase_name)     copy(Cdesc[Cid],sizeof Cdesc[] - 1,clase_descripcion)     Cexpe[Cid] = clase_experiencia     Cvida[Cid] = clase_vida     Cchal[Cid] = clase_chaleco }
this? ...

and the last i dont understend xD
Porta0123 is offline
Black Rose
Veteran Member
Join Date: Feb 2011
Location: Stockholm, Sweden
Old 07-06-2014 , 22:15   Re: how to set one id
Reply With Quote #5

When using register_native() with style set to 1, you have to use param_convert() to be able to read the strings.
I don't know the technical reason of it.
You need to index all of the variables. Cexpe, Cvida, Cchal as well assuming they are unique to each class. However you don't have to create a second dimension of 33 since they're not arrays.
__________________

Last edited by Black Rose; 07-06-2014 at 22:19.
Black Rose is offline
Porta0123
Member
Join Date: Apr 2014
Location: Spain
Old 07-07-2014 , 08:24   Re: how to set one id
Reply With Quote #6

Code:
new Cname[MAX_CLASSES] new Cdesc[MAX_CLASSES] new Cexpe[MAX_CLASSES] new Cvida[MAX_CLASSES] new Cchal[MAX_CLASSES] public native_neo_register_class(const clase_name[], const clase_descripcion[],clase_experiencia,clase_vida, clase_chaleco) {     param_convert(1);     param_convert(2);     copy(Cname,sizeof Cname[] - 1,clase_name)     copy(Cdesc,sizeof Cdesc[] - 1,clase_descripcion)     Cexpe[MAX_CLASSES-1]= clase_experiencia     Cvida[MAX_CLASSES-1] = clase_vida     Cchal[MAX_CLASSES-1] = clase_chaleco }

like this?
Porta0123 is offline
Black Rose
Veteran Member
Join Date: Feb 2011
Location: Stockholm, Sweden
Old 07-07-2014 , 16:32   Re: how to set one id
Reply With Quote #7

Re-add the [33] to Cname and Cdec since those are strings.

You have to define which class index of Cname and Cdesc that has to be written to.

MAX_CLASSES-1 will always remain the same meaning you will overwrite every time you use this native. I'm guessing you don't want that. You need global/static variable that is increasing at the end of this native.
__________________
Black Rose is offline
Porta0123
Member
Join Date: Apr 2014
Location: Spain
Old 07-08-2014 , 08:53   Re: how to set one id
Reply With Quote #8

yes... i want do the same than Cod-Mod and ZP...

1) get all .amxx in "classes.ini"
2) with one menu open the .amxx
etc...

but i donw know how...

maybe... this?

Code:
new Cname[MAX_CLASSES][33] new Cdesc[MAX_CLASSES][33] new Cexpe[MAX_CLASSES] new Cvida[MAX_CLASSES] new Cchal[MAX_CLASSES] new theid public native_neo_register_class(const clase_name[], const clase_descripcion[],clase_experiencia,clase_vida, clase_chaleco) {     param_convert(1);     param_convert(2);     copy(Cname[theid],sizeof Cname[] - 1,clase_name)     copy(Cdesc[theid],sizeof Cdesc[] - 1,clase_descripcion)     Cexpe[theid]= clase_experiencia     Cvida[theid] = clase_vida     Cchal[theid] = clase_chaleco     theid++ }

Last edited by Porta0123; 07-08-2014 at 09:00.
Porta0123 is offline
Black Rose
Veteran Member
Join Date: Feb 2011
Location: Stockholm, Sweden
Old 07-08-2014 , 12:23   Re: how to set one id
Reply With Quote #9

That code looks good. Didn't understand 1 & 2.
__________________

Last edited by Black Rose; 07-08-2014 at 12:24.
Black Rose is offline
Porta0123
Member
Join Date: Apr 2014
Location: Spain
Old 07-08-2014 , 14:39   Re: how to set one id
Reply With Quote #10

i want do the same than Cod-Mod ...

its register the plugin whitout add it in plugins.ini
this will works?
Code:
public plugin_init() {     register_plugin(PLUGIN, VERSION, AUTHOR)     //registrar clases     new Path[256];     get_configsdir(Path, charsmax(Path));     formatex(Path, charsmax(Path),"%s/%s", Path, gFileName);         if(!file_exists(Path))     {         client_print(0, print_chat, "[NeoDeathMatch] El archivo %s no existe", gFileName);         return PLUGIN_HANDLED;     }             new f = fopen(Path, "rt");             new iName[ITEMSLEN+1];       new Item;           while(!feof(f))     {         fgets(f, iName, charsmax(iName));                 if(!iName[0] || iName[0] == ';'         || iName[0] == '/' && iName[1] == '/' ) continue;                   copy(gItems[Item], charsmax(gItems), iName);           Item++;                                                         if(Item >= Cid) break;                 new plugin_id = find_plugin_byfile(iName) // Tira -1 si no lo encuentra.         new forwards_id, null_id;         if( plugin_id == INVALID_PLUGIN_ID )         {                         return log_error(AMX_ERR_NOTFOUND, "Plugin no encontrado")         }         else         {             forwards_id = CreateOneForward(plugin_id, "plugin_init", FP_CELL, FP_STRING)                         if( forwards_id < 0 )             {                 return log_error(AMX_ERR_NATIVE, "Error Creando Forward")             }             else             {             if( !ExecuteForward(forwards_id, null_id) )             {                 return log_error(AMX_ERR_NATIVE, "Error executando Forward")             }             else             {                 DestroyForward(forwards_id);             }             }         }         return 1                 }     fclose(f);     return 1 }

Last edited by Porta0123; 07-08-2014 at 14:40.
Porta0123 is offline
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 21:07.


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