SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help

Reply
 
Thread Tools Display Modes
Old 05/01/2020, 03:44 PM   #1
Filbert
Huge Clucker
 
Join Date: May 2016
Posts: 204
Reputation: 1
Question Clan ID's

Hello, i wanna make so that if someone create a clan using for example /createclan, the "ClanID" will be "(Previous ClanID) + 1". So the ClanID's will be 1,2,3,4,5,...
The "ClanName" and "ClanID" will be saved in "clans" table. And the creator of the clan will have "pClanID = the id that has been created)" in his "accounts" table.

Then, if someone join to a clan, his "pClanID" will be saved as the "ClanID".

Hope that illustrate what i want
Filbert is offline   Reply With Quote
Old 06/01/2020, 10:12 PM   #2
cipi89
Little Clucker
 
Join Date: Sep 2018
Posts: 17
Reputation: 3
Default Re: Clan ID's

I could help you if you're using Y_INI but I don't think thats the case, I still don't have experience with mysql.
I've created fully operational Clan system on my server in y_ini.
cipi89 is offline   Reply With Quote
Old 06/01/2020, 11:39 PM   #3
IzadorO
Huge Clucker
 
IzadorO's Avatar
 
Join Date: Feb 2015
Location: Scotland, Glasgow
Posts: 201
Reputation: 17
Default Re: Clan ID's

What you need to do is, well, what I do is, create a bool variable within the clan enum called clanExists or something.

When you create a clan, loop from 0 through to your MAX_CLANS definition, and check if the bool variable clanExists equals false, then create one.

Same with loading, the IDs should always be assigned themselves and no external actions should be took to force IDs to assign differently.
__________________
IzadorO is offline   Reply With Quote
Old 07/01/2020, 03:02 AM   #4
Filbert
Huge Clucker
 
Join Date: May 2016
Posts: 204
Reputation: 1
Default Re: Clan ID's

Quote:
Originally Posted by IzadorO View Post
What you need to do is, well, what I do is, create a bool variable within the clan enum called clanExists or something.

When you create a clan, loop from 0 through to your MAX_CLANS definition, and check if the bool variable clanExists equals false, then create one.

Same with loading, the IDs should always be assigned themselves and no external actions should be took to force IDs to assign differently.
So how to make the clanid automatically do like previous clanid + 1? Sorry for my bad english

I use mysql anyway
Filbert is offline   Reply With Quote
Old 07/01/2020, 04:57 AM   #5
IzadorO
Huge Clucker
 
IzadorO's Avatar
 
Join Date: Feb 2015
Location: Scotland, Glasgow
Posts: 201
Reputation: 17
Default Re: Clan ID's

It will automatically do it itself for the enum ID once a new one is created. So say you create a clan, slot 0 doesn't have a clan as the clanExists variable is set to false, so the next clan created would take slot 0. And the next would take 1, etc.

You really only need to make sure you've structured it correctly and you don't need to worry about mismatched IDs.
__________________
IzadorO is offline   Reply With Quote
Old 07/01/2020, 07:24 PM   #6
RoboN1X
Huge Clucker
 
RoboN1X's Avatar
 
Join Date: Feb 2011
Location: Indonesia
Posts: 416
Reputation: 99
Default Re: Clan ID's

use AUTO_INCREMENT for clan id in the clan table when a clan is inserted using cache_insert_id(), you dont have to specify any id in the insert query...

in case you still need to check for previous id do a query like this:
Code:
SELECT MAX(ClanID) FROM Clans

Code:
new ClanID = cache_insert_id();
// use ClanID = pClanID
__________________
Need Help? Use Search, WIKI, and FAQ
RoboN1X is offline   Reply With Quote
Old 07/01/2020, 09:08 PM   #7
Pottus
High-roller
 
Pottus's Avatar
 
Join Date: Jun 2012
Posts: 4,892
Reputation: 1321
Default Re: Clan ID's

Hey Filbert I know it is a bit off topic here but just wanted to suggest something for you. You have been making a lot of scripting help questions which is good so I thought this would help you out a lot and result in not getting stuck as often.

https://forum.sa-mp.com/showthread.php?t=597338
Pottus is offline   Reply With Quote
Old 08/01/2020, 04:32 AM   #8
KensPTV
Big Clucker
 
KensPTV's Avatar
 
Join Date: Oct 2019
Location: Vietnamese
Posts: 107
Reputation: 1
Default Re: Clan ID's

Show us code
__________________
Kens.P TV @ Youtuber
Scripting @ Samp
Adminstrator @ Designer @ [KG:RP]
KensPTV is offline   Reply With Quote
Reply

Thread Tools
Display Modes

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
[Include] clan.inc -> Easy-to-use, plug-n-play clan system fiki574 Includes 123 25/12/2015 08:11 PM
[FilterScript] Clan Tag + Clan Area Creator(v1.2) PrinceKumar Filterscripts 12 15/12/2015 10:28 PM
Clan Skin for only clan members Hammad97 Scripting Help 2 05/01/2014 07:57 PM
clan ucp thefatshizms Scripting Help 0 22/07/2012 10:16 PM
Clan JoBv16 Help Archive 1 14/02/2011 04:27 PM


All times are GMT. The time now is 12:02 PM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.