Raised This Month: $51 Target: $400
 12% 

Questions about natives


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Shaman
Senior Member
Join Date: Dec 2006
Location: Istanbul, Turkey
Old 09-08-2007 , 12:38   Questions about natives
Reply With Quote #1

1-How can I create natives?
2-How can I return integers, handles, floats, etc.?
3-How can I return strings? (I think I have to use referance thing?!?!)
4-How can I get/return arrays. (Float array, string array, etc.)
5-What does 'MarkNativeAsOptional()' do? Do I have to use it? How can I use it?

I want to add some natives to SStocks. I hope I can help you code easier.
__________________

Last edited by Shaman; 09-08-2007 at 12:41.
Shaman is offline
Send a message via ICQ to Shaman Send a message via AIM to Shaman Send a message via MSN to Shaman Send a message via Yahoo to Shaman
Nican
Veteran Member
Join Date: Jan 2006
Location: NY
Old 09-08-2007 , 12:47   Re: Questions about natives
Reply With Quote #2

From my MYSQL manager plugin:

PHP Code:
public bool:AskPluginLoad(Handle:myselfbool:lateString:Error[])
{
  
// General
  
CreateNative("DB_GetColumnId"Db_GetColumnId);
  
CreateNative("DB_EnableId"Db_EnableColumn);
  
CreateNative("DB_DisableId"Db_DisableColumn);
  
CreateNative("DB_ColumnType"ReturnColumnType);
  
CreateNative("DB_GetHandle"DB_ReturnHandle);
  
//CreateNative("DB_CreateRow", DB_CreateNewRow);
  
  
CreateNative("DB_SetInfo"SetColumnInfo);
  
CreateNative("DB_SetInfoString"SetColumnInfoString);
  
  
CreateNative("DB_GetColumn"GetColumnInfo);
  
CreateNative("DB_GetColumnString"GetColumnInfoString);

  return 
true;

A simple native:
PHP Code:
//Client, column
public GetColumnInfo(Handle:plugin,argc){
    if(
argc==2){
        new 
client GetNativeCell(1);
        if(
client MAXPLAYERS )
            
ThrowNativeError(0"Invalid client!");
            
        new 
column GetNativeCell(2);
        if(
column Totalcount )
            
ThrowNativeError(0"Invalid column!");            
        
        switch(  
GetColumnType(column) ){
            case 
DB_INTDB_FLOAT: {
                return 
GetArrayCellGetArrayCell(adt_adress,column) , client);
            }
            case 
DB_STRINGThrowNativeError(0"Column is not a string!");
        }        
    }
    return -
1;
}

//Client, column, sting, maxsize
public GetColumnInfoString(Handle:plugin,argc){
    if(
argc==4){
        new 
client GetNativeCell(1);
        if(
client MAXPLAYERS )
            
ThrowNativeError(0"Invalid client!");
            
        new 
column GetNativeCell(2);
        if(
column Totalcount )
            
ThrowNativeError(0"Invalid column!");            
        
        switch( 
GetColumnType(column) ){
            case 
DB_INTDB_FLOATThrowNativeError(0"Column is not a int/float!");
            case 
DB_STRING: {
                 new 
size GetNativeCell(4);
                 new 
String:temp[size];
                 
GetArrayStringGetArrayCell(adt_adress,column) , column ,tempsize);
                
SetNativeString(3tempsize);
            }
        }
    }

and the page with the native functions:
http://sm.nican132.com/index.php?fas...le&id=1&type=&
__________________
http://www.nican132.com
I require reputation!
Nican is offline
Send a message via ICQ to Nican Send a message via MSN to Nican
Shaman
Senior Member
Join Date: Dec 2006
Location: Istanbul, Turkey
Old 09-08-2007 , 13:07   Re: Questions about natives
Reply With Quote #4

Thanks Bail. I didn't saw that and looked at "Natives (SourceMod Development)"
__________________
Shaman is offline
Send a message via ICQ to Shaman Send a message via AIM to Shaman Send a message via MSN to Shaman Send a message via Yahoo to Shaman
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 02:51.


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