Vice City: Multiplayer

Server Development => Scripting and Server Management => Topic started by: Nihongo^ on Sep 08, 2016, 12:11 PM

Title: Clanstats in database
Post by: Nihongo^ on Sep 08, 2016, 12:11 PM
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 ]
}
Title: Re: Clanstats in database
Post by: EK.IceFlake on Sep 08, 2016, 12:22 PM
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
Title: Re: Clanstats in database
Post by: Nihongo^ on Sep 08, 2016, 12:48 PM
can u give example  ?
Title: Re: Clanstats in database
Post by: EK.IceFlake on Sep 08, 2016, 03:05 PM
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
Title: Re: Clanstats in database
Post by: Nihongo^ on Sep 08, 2016, 03:24 PM
Thanks for reply well its see like this ? ( just example )

(https://forum.vc-mp.org/proxy.php?request=http%3A%2F%2Fi67.tinypic.com%2F2qn4bx5.png&hash=fdd2dfb064fab85f40a26d11473f89de87fdc2fe)
Title: Re: Clanstats in database
Post by: Cool on Sep 08, 2016, 03:49 PM
Wrong Board next time post in right place.
Title: Re: Clanstats in database
Post by: Nihongo^ on Sep 08, 2016, 03:51 PM
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
Title: Re: Clanstats in database
Post by: Thijn on Sep 08, 2016, 04:38 PM
This one
Title: Re: Clanstats in database
Post by: EK.IceFlake on Sep 08, 2016, 05:32 PM
Quote from: Nihongo^ on Sep 08, 2016, 03:24 PMThanks for reply well its see like this ? ( just example )

(https://forum.vc-mp.org/proxy.php?request=http%3A%2F%2Fi67.tinypic.com%2F2qn4bx5.png&hash=fdd2dfb064fab85f40a26d11473f89de87fdc2fe)
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
Title: Re: Clanstats in database
Post by: Nihongo^ on Sep 08, 2016, 07:35 PM
what about gettag function where i place it  ?
Title: Re: Clanstats in database
Post by: 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
Title: Re: Clanstats in database
Post by: 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.
Title: Re: Clanstats in database
Post by: 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
Title: Re: Clanstats in database
Post by: KAKAN on Sep 09, 2016, 12:03 PM
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
Title: Re: Clanstats in database
Post by: KAKAN on Sep 09, 2016, 03:25 PM
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.
Title: Re: Clanstats in database
Post by: Nihongo^ on Sep 09, 2016, 04:01 PM
its giving bug at line 536 which is

Quoteif ( Tag == null )   

btw i act upon your advice but my script still not loaded
Title: Re: Clanstats in database
Post by: KAKAN on Sep 09, 2016, 04:44 PM
Quote from: Nihongo^ on Sep 09, 2016, 04:01 PMits giving bug at line 536 which is

Quoteif ( Tag == null )   

btw i act upon your advice but my script still not loaded
http://pastebin.com/UcxKY5je
Try that. It's pretty much the same thing. Just try, don't ask me why. SLC knows about it.
Title: Re: Clanstats in database
Post by: Nihongo^ on Sep 10, 2016, 07:20 AM
can't simply used that function some mind needed like i have to replace

Quotereturn Clan;
to
Quotereturn FindClan[ Tag ];

btw again its giving bug at

if( Clan == null )
Title: Re: Clanstats in database
Post by: KAKAN on Sep 10, 2016, 08:44 AM
Quote from: Nihongo^ on Sep 10, 2016, 07:20 AMcan't simply used that function some mind needed like i have to replace

Quotereturn Clan;
to
Quotereturn FindClan[ Tag ];

btw again its giving bug at

if( Clan == null )

add this before that:-
print( typeof Clan ); print( typeof clans );
Title: Re: Clanstats in database
Post by: Nihongo^ on Sep 10, 2016, 08:58 AM
wait problem is not in print Tag i remove it
it still giving bug there
Title: Re: Clanstats in database
Post by: KAKAN on Sep 10, 2016, 12:40 PM
Quote from: Nihongo^ on Sep 10, 2016, 08:58 AMwait problem is not in print Tag i remove it
it still giving bug there
Just add it back and tell me the output.
Title: Re: Clanstats in database
Post by: Nihongo^ on Sep 10, 2016, 01:06 PM
ok i'll added but i can't get it what is print( typeof clans ); ?

what does "type of clan" there's no function on it -.-
Title: Re: Clanstats in database
Post by: KAKAN on Sep 10, 2016, 05:33 PM
Quote from: Nihongo^ on Sep 10, 2016, 01:06 PMok i'll added but i can't get it what is print( typeof clans ); ?

what does "type of clan" there's no function on it -.-

The function is self explanatory. It prints the "type of" shit.
For ex:
We know, "This is a string" It's a string. Try printing typeof "this is a string" it will output as string and so on.
Like that, doing typeof 123 will print integer and doing typeof 123.123 will output float and so on.
So, according to our script, typeof clans should output array and typeof Tag should output either string or null which is what I want to see.
Title: Re: Clanstats in database
Post by: Nihongo^ on Sep 10, 2016, 06:07 PM
Like this ?
see clear http://oi65.tinypic.com/6e3ubs.jpg

(https://forum.vc-mp.org/proxy.php?request=http%3A%2F%2Fi65.tinypic.com%2F6e3ubs.png&hash=929e39b28b74d4d3eb911506c85343ccbc78ad04)
Title: Re: Clanstats in database
Post by: vito on Sep 10, 2016, 06:29 PM
look at 534 , there
Title: Re: Clanstats in database
Post by: KAKAN on Sep 10, 2016, 06:36 PM
Oh man, the problem is you're trying to use 'Tag' in the function find.
Replace that line with this:-
local Tag = clans.find(tag);
Title: Re: Clanstats in database
Post by: Nihongo^ on Sep 11, 2016, 08:12 AM
oh so i replace , to ; my script run successful

see full image = http://i64.tinypic.com/2n9j2hv.png

(https://forum.vc-mp.org/proxy.php?request=http%3A%2F%2Fi64.tinypic.com%2F2n9j2hv.png&hash=83ead0a2bfb15c7cf90023347ea4792db01a9293)

but when i put the
Quoteprint( GetTag( "VU" ) )
it gave error again at same place :(

see full image = http://i67.tinypic.com/25kk9dt.png

(https://forum.vc-mp.org/proxy.php?request=http%3A%2F%2Fi67.tinypic.com%2F25kk9dt.png&hash=f0fa17e35224658f881987755c07cab6474e7686)
Title: Re: Clanstats in database
Post by: KAKAN on Sep 11, 2016, 10:45 AM
you're printing this before having the clans array.
See below it, clans array is created after that.
So, put it after the clans array is created and the clans are inserted.
Title: Re: Clanstats in database
Post by: Nihongo^ on Sep 11, 2016, 10:57 AM
oh well ok i place it after the array it gave bug now here

see full = http://i67.tinypic.com/2d2dcoy.png

(https://forum.vc-mp.org/proxy.php?request=http%3A%2F%2Fi67.tinypic.com%2F2d2dcoy.png&hash=baa63d42e9b117ddeec445d722ec0fe2f03f5233)

so i remove the 
Quoteprint( typeof clans )

this happend
see full = http://i66.tinypic.com/1zx1pjo.png

(https://forum.vc-mp.org/proxy.php?request=http%3A%2F%2Fi66.tinypic.com%2F1zx1pjo.png&hash=493c34e62467b8691f4dcb27854a0506e8b2f2dd)
Title: Re: Clanstats in database
Post by: DizzasTeR on Sep 11, 2016, 11:18 AM
if( Tag = null )

Should be

if( Tag == null )
Title: Re: Clanstats in database
Post by: . on Sep 11, 2016, 11:44 AM
Quote from: Nihongo^ on Sep 08, 2016, 12:11 PMhello 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 ]
}

How the hell did this question which only required a Yes or No answer took 3 f*ing pages? Where the answer was obviously Yes because what can be stored into text files can also be stored into a database (duh!). How dafuq is this even possible? How did it get to this? Sorry, I just couldn't take it anymore.
Title: Re: Clanstats in database
Post by: Nihongo^ on Sep 11, 2016, 01:01 PM
keep calm i can't make topic every time if u want i will change the topic name
Title: Re: Clanstats in database
Post by: . on Sep 11, 2016, 01:06 PM
Quote from: Nihongo^ on Sep 11, 2016, 01:01 PMkeep calm i can't make topic every time if u want i will change the topic name

This isn't about the topic title man. You simply asked if you can save a couple names in a database. To which the answer was a simple Yes. But then this crap escalated to a whole new area because you couldn't even get the spaces right.

You don't know what a number, semicolon, dot, value, variable, text, function etc. is or does. If someone doesn't hand you the code and tell you exactly where and how to paste it you're completely lost. Why not just stick to playing? Or at least get some practice before going this far off the reservation.
Title: Re: Clanstats in database
Post by: Nihongo^ on Sep 11, 2016, 01:13 PM
its werid after getting the answere "YES" i lock the topic and create another one

btw i know about semicolan numbers blah but i was completly forgot about it i start scripting after a long time
Title: Re: Clanstats in database
Post by: Nihongo^ on Sep 11, 2016, 02:12 PM
Quote from: Doom_Kill3R on Sep 11, 2016, 11:18 AMif( Tag = null )

Should be

if( Tag == null )

Sorry about the double post thanks doom its work but its print 0 in concel

see full = http://i66.tinypic.com/50qz5v.png

(https://forum.vc-mp.org/proxy.php?request=http%3A%2F%2Fi66.tinypic.com%2F50qz5v.png&hash=7ce6f6d7c6f0e912e1aeea3b0215b8310df9e1dc)
Title: Re: Clanstats in database
Post by: KAKAN on Sep 12, 2016, 06:56 AM
you can see it clearly. That means the clan doesn't exist. Make sure that the clans are inserted into that array.
Title: Re: Clanstats in database
Post by: Nihongo^ on Sep 13, 2016, 06:02 AM
Quote from: KAKAN on Sep 12, 2016, 06:56 AMyou can see it clearly. That means the clan doesn't exist. Make sure that the clans are inserted into that array.

Sorry i found some mistakes in code which has been fixed  :P why did not you tell  me about inserting tags in clan array like

Quoteclans <- ["vu"];

now my script is loaded and he found the tag but its print something weird
like ( array : 0x005D17B8)

http://oi67.tinypic.com/2hxocbb.jpg
Title: Re: Clanstats in database
Post by: KAKAN on Sep 13, 2016, 06:09 AM
You must use return Tag; and not return clans;