Clanstats in database

Started by Nihongo^, Sep 08, 2016, 12:11 PM

Previous topic - Next topic

Nihongo^

hello im using kartoz GetTag( string ) function we can add clans manually in note pad
but is it possible to add them into a database instead adding it on NOTEPAD ?
Quotefunction GetTag( string )
{
        local
        Tag = FindClan( string ).toupper(),                 // Getting the clan tag & switching it to upper case just to match the table regardless of case.
        // There needed the alliance in big letters
        // Clan Table for defining slots of clan sublevels [ Trainee, Rookie & Scout ]
        Clans = { VU_T = "VU", VU_R = "VU", TLK = "ULK", TLKR = "ULK", MKT = "MK", MKS = "MK", DKR = "DK", DKT = "DK", DKS = "DK" };
       
         if ( Tag in Clans )    // Checking if the tag obtained through findclan( string ) is in Clan Table or not
        {
             return Clans[ Tag ];      // If yes, its time to calling their corresponding slots from the table
        }
        else return FindClan( string );    // if not, then tag will be as it is [ If no slot will be alloted for a clan then script may recognize sublevels as other clans ]
}

EK.IceFlake

you need to use arrays
you also need mysql or sqlite
then you need to got a table called 'clans'
you will got it from them, and use this function:
array.push(/*value*/);
to add a value to the array
and then you will use array.find

good luck

Nihongo^


EK.IceFlake

#3
im feeling very lazy now so this code is probably poorly written and might have some errors
function onScriptLoad()
{
    clandb <- ConnectSQL("clans.sqli");
    clans <- [];
    local clanq = QuerySQL(clandb, "select * from clans");
    while (GetSQLNextRow(clanq))
    {
        clans.push(GetSQLColumnData(clanq, 0));
    }
}
now you will have a global array called 'clans' you can use it anywhere you want with ex clans.find("EK");
you will need to add the table clans by hand, with the first row being the clan tag
you can also script the server to do that with this query:
create table if not exists clans (tag text)
and you can add additional clan information if you wish

Nihongo^

Thanks for reply well its see like this ? ( just example )


Cool

Wrong Board next time post in right place.

Nihongo^

Quote from: Hercules on Sep 08, 2016, 03:49 PMWrong Board next time post in right place.
will you please tell me
which board is for server bugs relate and for Discussion

Thijn


EK.IceFlake

Quote from: Nihongo^ on Sep 08, 2016, 03:24 PMThanks for reply well its see like this ? ( just example )


as long as that clan tag thing is on first row, yes
also, any value other than the first row is ignored
you need to add, for example, VU and VU_T seperately

Nihongo^

what about gettag function where i place it  ?

Shovon^

:) can u give me the script of clan after you figure put the fix??? I also need it
Iam the best and i only believe in Allah

Conatact me here on IRC:  #shovon^ @LUnet

KAKAN

Quote from: Shovon^ on Sep 09, 2016, 02:49 AM:) can u give me the script of clan after you figure put the fix??? I also need it
another nerd here lol
Quote from: Nihongo^ on Sep 08, 2016, 07:35 PMwhat about gettag function where i place it  ?
Just edit the function a bit to use the array instead of that table.
oh no

Nihongo^

Quote from: KAKAN on Sep 09, 2016, 06:57 AM
Quote from: Shovon^ on Sep 09, 2016, 02:49 AM:) can u give me the script of clan after you figure put the fix??? I also need it
another nerd here lol
Quote from: Nihongo^ on Sep 08, 2016, 07:35 PMwhat about gettag function where i place it  ?
Just edit the function a bit to use the array instead of that table.
KAKAN will you please give little bit example ? i mean a way to use that array on my GetTag function ? i'm confused

KAKAN

#13
Quote from: Nihongo^ on Sep 09, 2016, 09:03 AM
Quote from: KAKAN on Sep 09, 2016, 06:57 AM
Quote from: Shovon^ on Sep 09, 2016, 02:49 AM:) can u give me the script of clan after you figure put the fix??? I also need it
another nerd here lol
Quote from: Nihongo^ on Sep 08, 2016, 07:35 PMwhat about gettag function where i place it  ?
Just edit the function a bit to use the array instead of that table.
KAKAN will you please give little bit example ? i mean a way to use that array on my GetTag function ? i'm confused
sure. Take this as an example:-
function GetTag( tag ){
//The global array is 'clans'
local clan = clans.find( tag.tolower() ); /*Find the tag.
 Everything must be lowercase in your array.
 Else simply remove the .tolower();
*/
if( tag == null ){
//The clan tag isn't registered here...
return 0;
//Do whatever you want.
}
else return clan; //The clan is registered
//If something unknown happens( which will never will! )
return 0;
}
Usage: print( GetTag( "VU" ) )Returns: VU
Example #2: print( GetTag( "SD" ) );Returns: 0
oh no

KAKAN

Quote from: Nihongo^ on Sep 09, 2016, 02:08 PMwell its give error when i put
Quoteprint( GetTag( "VU" ) )
to check the clans
Remove all the spaces from that function and then add it yourself.
oh no