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 ]
}
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
can u give example ?
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
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)
Wrong Board next time post in right place.
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
This one
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
what about gettag function where i place it ?
:) can u give me the script of clan after you figure put the fix??? I also need it
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.
Quote from: KAKAN on Sep 09, 2016, 06:57 AMQuote 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
Quote from: Nihongo^ on Sep 09, 2016, 09:03 AMQuote from: KAKAN on Sep 09, 2016, 06:57 AMQuote 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
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.
its giving bug at line 536 which is
Quoteif ( Tag == null )
btw i act upon your advice but my script still not loaded
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.
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 )
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 );
wait problem is not in print Tag i remove it
it still giving bug there
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.
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 -.-
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.
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)
look at 534 , there
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);
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)
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.
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)
if( Tag = null )
Should be
if( Tag == null )
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.
keep calm i can't make topic every time if u want i will change the topic name
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.
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
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)
you can see it clearly. That means the clan doesn't exist. Make sure that the clans are inserted into that array.
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
You must use return Tag; and not return clans;