27.04.2012, 15:27
(
Последний раз редактировалось fiki574; 17.04.2013 в 09:03.
Причина: VERSION 1.4
)
CLAN SYSTEM v1.4
UPDATED ON 17.4.2013.
INTRO:
Hello! As you can see, have finished my latest project which is my own clan system! Havent found nor saw any clan systems round here on SAMP forums, so I decided to make one! This clan system has a lots of features! Also, this system is using MySQL plugin for efficient saving and loading! Now, lets start!
__________________________________________________ _______________________________________________
CHANGELOG:
Код:
[15.8.2012. | 21:45 | Version 1.1] Fixed bug involving "GetClanMembers" function which would return just the last member's name -> now should and will return all members' names [4.10.2012. | 11:40 | Version 1.2] Added "SendMessageToClanMembersEx" - this function doesn't have "playerid" parameter and has "clan" parameter Added "GetClanWeapon" - this function will return weapon ID from specific slot in certain clan Added optional parameters named "old_weapX" to "ChangeClanWeapons" - now, you don't have to change all 3 clan weapons if you dont want too, for example you can just simply change 1 or 2 without touching third one [15.4.2013. | 20:45 | Version 1.3] Fixed problem involving "GetClanWeapon" and "ChangeClanWeapons" usage that would cause bunch of errors in output (no more bugs and errors) [17.4.2013. | 11:20 | Version 1.4] Added "ChangeClanTag" function - easily change some clan's tag Added "GetClanTag" function - retrieve tag of specific clan Added "GetClanPassword" function - get clan's password Added "UseClanTags" function - enable/disable clan [TAG] showing on playerlist (requires player name change, watch out when using saving systems) Added "UseClanPasswords" function - player must enter correct password to play in server, if he fails MAX_PASS_FAILS times, he gets kicked Added "OnPlayerChangeClanTag" callback - called when "ChangeClanTag" is performed Updated and changed 3 optional values in "ChangeClanWeapons" to just 1 (old_weap for all) Updated some function's messages with some more color codes
__________________________________________________ _______________________________________________
NATIVES:
Total of 20 custom natives that helps you to properly use this clan system! Here, I am going to show you all natives and examples of using them!
List of the natives:
pawn Код:
native CreateClan(playerid, clan_name[], clan_tag[], clan_pass[], clan_description[], clan_motd[], weap1, weap2, weap3);
native AddPlayerToClan(playerid, addid);
native RemovePlayerFromClan(playerid, removeid);
native LeaveClan(playerid);
native DisbandClan(playerid);
native ChangePlayerClanRank(playerid, giveid, rank);
native ChangeClanMOTD(playerid, new_motd[]);
native ChangeClanDescription(playerid, new_description[]);
native ChangeClanWeapons(playerid, new_weap1 = old_weap, new_weap2 = old_weap, new_weap3 = old_weap);
native ChangeClanPassword(playerid, new_pass[]);
native ChangeClanTag(playerid, new_tag[]);
native IsPlayerAnyClanMember(playerid);
native IsPlayerClanMember(playerid, clan_name[]);
native GetPlayerClan(playerid);
native GetPlayerClanRank(playerid);
native GetClanMOTD(clan[]);
native GetClanDescription(clan[]);
native GetClanMembers(clan[]);
native GetClanWeapon(clan[], weap_slot);
native GetClanTag(clan[]);
native GetClanPassword(clan[]);
native UseClanTags(bool:use = true);
native UseClanPasswords(bool:use = true);
native SendMessageToClanMembers(playerid, color, msg[]);
native SendMessageToClanMembersEx(clan[], color, msg[]);
Now, here is explanation and example usage of each native!
Creating a clan:
pawn Код:
native CreateClan(playerid, clan_name[], clan_tag[], clan_pass[], clan_description[], clan_motd[], weap1, weap2, weap3);
//playerid - for calling function and sending a message
//clan_name[] - name of your clan
//clan_tag[] - tag that will be saved to your clan's stats
//clan_pass[] - password for your clan
//clan_description[] - describe your clan in few words
//clan_motd[] - clan's message of the day
//weap1 - weapon 1 that will be given OnPlayerSpawn
//weap2 - weapon 1 that will be given OnPlayerSpawn
//weap3 - weapon 1 that will be given OnPlayerSpawn
pawn Код:
COMMAND:cclan(playerid,params[])
{
new cname[30], ctag[30], cpass[30], cw1, cw2, cw3;
if(!sscanf(params, "s[30]s[30]s[30]iii", cname, ctag, cpass, cw1, cw2, cw3))
{
CreateClan(playerid, cname, ctag, cpass, "", "", cw1, cw2, cw3);
return 1;
}
else SendClientMessage(playerid,-1,"USAGE: /cclan <clan-name> <clan-tag> <clan-pass> <weap1> <weap2> <weap3>");
return 1;
}
Adding player to clan:
pawn Код:
native AddPlayerToClan(playerid, addid);
//playerid - player that perfoms the action
//addid - ID of player that will be added to clan
pawn Код:
COMMAND:addplayer(playerid,params[])
{
new target;
if(!sscanf(params, "u", target))
{
AddPlayerToClan(playerid, target);
return 1;
}
else SendClientMessage(playerid,-1,"USAGE: /addplayer <playerid>");
return 1;
}
Removing player from clan:
pawn Код:
native RemovePlayerFromClan(playerid, removeid);
//playerid - player that will perform action
//removeid - player that will be remove from clan
pawn Код:
COMMAND:remplayer(playerid,params[])
{
new target;
if(!sscanf(params, "u", target))
{
RemovePlayerFromClan(playerid, target);
return 1;
}
else SendClientMessage(playerid,-1,"USAGE: /remplayer <playerid>");
return 1;
}
Leaving clan:
pawn Код:
native LeaveClan(playerid);
//playerid - player that will leave the clan
pawn Код:
COMMAND:cleave(playerid,params[])
{
return LeaveClan(playerid);
}
Disbanding clan:
pawn Код:
native DisbandClan(playerid);
//playerid - player that will disband their clan
pawn Код:
COMMAND:cdisband(playerid,params[])
{
return DisbandClan(playerid);
}
Changing player's clan rank:
pawn Код:
native ChangePlayerClanRank(playerid, giveid, rank);
//playerid - player performing the action
//giveid - player that will have their rank changed
//rank - assign new rank to giveid (1 - member, 2 - officer, 3 - co-leader, 4 - leader)
pawn Код:
COMMAND:changerank(playerid,params[])
{
new target, crank;
if(!sscanf(params, "ui", target, crank))
{
ChangePlayerClanRank(playerid, target, crank);
return 1;
}
else SendClientMessage(playerid,-1,"USAGE: /changerank <playerid> <rank>");
return 1;
}
Changing clan's message of the day:
pawn Код:
native ChangeClanMOTD(playerid, new_motd[]);
//playerid - player that will change MOTD
//new_motd[] - new message of the day
pawn Код:
COMMAND:changemotd(playerid,params[])
{
new cmotd[100];
if(!sscanf(params, "s[100]", cmotd))
{
ChangeClanMOTD(playerid, cmotd);
return 1;
}
else SendClientMessage(playerid,-1,"USAGE: /changerank <new-motd>");
return 1;
}
Changing clan's description:
pawn Код:
native ChangeClanDescription(playerid, new_description[]);
//playerid - player that will perform change
//new_description[] - brand new clan description
pawn Код:
COMMAND:changedes(playerid,params[])
{
new cdes[200];
if(!sscanf(params, "s[200]", cdes))
{
ChangeClanDescription(playerid, cdes);
return 1;
}
else SendClientMessage(playerid,-1,"USAGE: /changedes <new-description>");
return 1;
}
Changing clan's weapons:
pawn Код:
native ChangeClanWeapons(playerid, new_weap1 = old_weap1, new_weap2 = old_weap2, new_weap3 = old_weap3);
//playerid - player performing command
//new_weap1 = old_weap1 - new/old weapon 1, given OnPlayerSpawn
//new_weap2 = old_weap2 - new/old weapon 2, given OnPlayerSpawn
//new_weap3 = old_weap3 - new/old weapon 3, given OnPlayerSpawn
pawn Код:
COMMAND:changeweaps(playerid,params[])
{
new cw1, cw2, cw3;
if(!sscanf(params, "iii", cw1, cw2, cw3))
{
ChangeClanWeapons(playerid, cw1, cw2, cw3);
return 1;
}
else SendClientMessage(playerid,-1,"USAGE: /changeweaps <weap1> <weap2> <weap3>");
return 1;
}
Changing clan's password:
pawn Код:
native ChangeClanPassword(playerid, newpass[]);
//playerid - player changing pass
//newpass[] - password that will replace old one
pawn Код:
COMMAND:changepass(playerid,params[])
{
new cpass[20];
if(!sscanf(params, "s[20]", cpass))
{
ChangeClanPassword(playerid, cpass);
return 1;
}
else SendClientMessage(playerid,-1,"USAGE: /changepass <new-password>");
return 1;
}
pawn Код:
native ChangeClanTag(playerid, new_tag[]);
//playerid - player changing pass
//new_tag[] - tag that will replace old one
pawn Код:
COMMAND:changetag(playerid,params[])
{
new tag[10];
if(!sscanf(params, "s[10]", tag))
{
ChangeClanTag(playerid, tag);
return 1;
}
else SendClientMessage(playerid,-1,"USAGE: /changetag <new-tag>");
return 1;
}
pawn Код:
native IsPlayerAnyClanMember(playerid);
//playerid - player to check
//returns 1 if player is in clan, returns 0 if not
Checking if player is part of specific clan:
pawn Код:
native IsPlayerClanMember(playerid, clan_name[]);
//playerid - player to check
//clan_name[] - exact clan name
//will return 1 if player in "clan_name" clan, returns 0 if not
Getting name of player's clan:
pawn Код:
native GetPlayerClan(playerid);
//playerid - player to check
//returns string (clan's name) if player in clan
Getting clan rank of player:
pawn Код:
native GetPlayerClanRank(playerid);
//playerid - player to check
//returns player's clan rank (if in clan)
Getting clan's message of the day:
pawn Код:
native GetClanMOTD(clan[]);
//clan[] - clan to check
//returns message of the day of that specific "clan[]"
Getting clan's description:
pawn Код:
native GetClanDescription(clan[]);
//clan[] - clan to check
//returns description of that specific "clan[]"
Getting clan member names:
pawn Код:
native GetClanMembers(clan[]);
//clan[] - clan to check
//returns all player's name in a string
pawn Код:
native GetClanWeapon(clan[],weap_slot);
//clan - in which clan will the weapons be checked
//weap_slot - since you can have only 3 clan weapons, slots are - 1, 2 and 3
//returns weapon ID in "weap_slot"
pawn Код:
native GetClanTag(clan[]);
//clan - retrieve the tag
//returns clan tag as string
pawn Код:
native GetClanPassword(clan[]);
//clan - retrieve the tag
//returns clan password as string
pawn Код:
native UseClanTags(bool:use = true);
//use - do you want players to have [TAG] in front of their names
//NOTE: Should be used under "OnFilterScriptInit" or "OnGameModeInit"
pawn Код:
native UseClanPasswords(bool:use = true);
//use - players must input correct password to proceed to server
//NOTE: Should be used under "OnFilterScriptInit" or "OnGameModeInit"
pawn Код:
native SendMessageToClanMembers(playerid, color, msg[]);
//playerid - used in checking if player is in same clan as his clanmates
//color - message color
//msg[] - message to send
pawn Код:
native SendMessageToClanMembersEx(clan[], color, msg[]);
//clan[] - clan's members that will receive "msg"
//color - message color
//msg[] - message to send
CALLBACKS:
This system has a several custom callbacks that are called on performing specific natives!
Callbacks list:
pawn Код:
forward OnPlayerClanCreate(playerid, clan_name[]); //called when player creates a clan
forward OnPlayerAddPlayerToClan(playerid, addid, clan_name[]); //called on adding new member to clan
forward OnPlayerRemovePlayerFromClan(playerid, removeid, clan_name[]); //called when removing member from clan
forward OnPlayerLeaveClan(playerid, clan_name[]); //called when someone leaves some clan
forward OnPlayerDisbandClan(playerid, clan_name[]); //called when clan gets disbanded
forward OnPlayerChangeClanMOTD(playerid, new_motd[]); //called when clan's message of the day is changed
forward OnPlayerChangeClanDescription(playerid, new_description[]); //called when clan's description is changed
forward OnPlayerChangeClanWeapons(playerid, new_weap1, new_weap2, new_weap3); //called when clan weapons are changed
forward OnPlayerChangeClanPassword(playerid, new_pass[]); //called when clan password is changed
forward OnPlayerChangeClanTag(playerid, new_tag[]); //called when clan tag is changed
forward OnPlayerChangePlayerRank(playerid, giveid, new_rank); //called when someone get promoted/demoted
pawn Код:
public OnPlayerClanCreate(playerid, clan_name[])
{
new name[MAX_PLAYER_NAME];
GetPlayerName(playerid,name,sizeof(name));
printf("Player %s created clan named %s", name, clan_name);
return 1;
}
public OnPlayerAddPlayerToClan(playerid, addid, clan_name[])
{
new name[MAX_PLAYER_NAME];
GetPlayerName(playerid,name,sizeof(name));
new addname[MAX_PLAYER_NAME];
GetPlayerName(addid,addname,sizeof(addname));
printf("Player %s added player %s to clan %s", name, addname, clan_name);
return 1;
}
public OnPlayerRemovePlayerFromClan(playerid, removeid, clan_name[])
{
new name[MAX_PLAYER_NAME];
GetPlayerName(playerid,name,sizeof(name));
new remname[MAX_PLAYER_NAME];
GetPlayerName(removeid,remname,sizeof(remname));
printf("Player %s removed player %s from clan %s", name, remname, clan_name);
return 1;
}
public OnPlayerLeaveClan(playerid, clan_name[])
{
new name[MAX_PLAYER_NAME];
GetPlayerName(playerid,name,sizeof(name));
printf("Player %s left clan %s", name, clan_name);
return 1;
}
public OnPlayerDisbandClan(playerid, clan_name[])
{
new name[MAX_PLAYER_NAME];
GetPlayerName(playerid,name,sizeof(name));
printf("Player %s disbanded clan %s", name, clan_name);
return 1;
}
public OnPlayerChangeClanMOTD(playerid, new_motd[])
{
new name[MAX_PLAYER_NAME];
GetPlayerName(playerid,name,sizeof(name));
printf("Player %s changed clan's %s MOTD to %s", name, GetPlayerClan(playerid), new_motd);
return 1;
}
public OnPlayerChangeClanPassword(playerid, new_pass[])
{
new name[MAX_PLAYER_NAME];
GetPlayerName(playerid,name,sizeof(name));
printf("Player %s changed clan's %s password to %s", name, GetPlayerClan(playerid), new_pass);
return 1;
}
public OnPlayerChangeClanTag(playerid, new_tag[])
{
new name[MAX_PLAYER_NAME];
GetPlayerName(playerid,name,sizeof(name));
printf("Player %s changed clan's %s tag to %s", name, GetPlayerClan(playerid), new_tag);
return 1;
}
public OnPlayerChangePlayerRank(playerid, giveid, new_rank)
{
new name[MAX_PLAYER_NAME];
GetPlayerName(playerid,name,sizeof(name));
new givename[MAX_PLAYER_NAME];
GetPlayerName(giveid,givename,sizeof(givename));
printf("Player %s changed rank of player %s to %d", name, givename, new_rank);
return 1;
}
IMPORTANT NOTES:
- This system uses OnFilterScriptInit in itself
- This system uses OnPlayerSpawn in itself
- This system uses OnPlayerText in itself
- This system uses OnDialogResponse in itself
- This system uses OnPlayerConnect in itself
- This system uses it's own messages/notifications so there is no need of using extra SendClientMessages
- To use clan chat, you have to type symbol "$" first!
- You will need MySQL plugin from BlueG (click here)! NOTE: Has to be version R6 or R6-2, otherwise wont work!
- In this thread, I used ZCMD/sscanf only as example, but if you wanna copy/paste my examples in script, make sure you have ZCMD include and sscanf include + plugin (sscanf)
__________________________________________________ _______________________________________________
CREDITS:
fiki574_CRO - creating this system
Zeex - ZCMD include
****** - sscanf include + plugin
BlueG - MySQL include + plugin
__________________________________________________ _______________________________________________
DOWNLOAD:
Pastebin (v1.4) (newest, recommended)
<Mediafire link removed>
__________________________________________________ _______________________________________________
Hope you people like it! ^^
Best regards,
Fiki!