10.02.2017, 18:01
hey so I'm trying to make a clan system using dini but it isn't work when I join game with the tag it kick me as I ut wanted and when I set player clan member it should save his acc but it didn't and when he connect it should create it and load it here is the code:
thanks.
PHP код:
#include <Dini>
#include <dudb>
#define NewPath "Accounts/%s.ini"
public OnPlayerConnect(playerid)
{
new isname[MAX_PLAYER_NAME], file[256];
GetPlayerName(playerid, isname, sizeof(isname));
format(file, sizeof(file), NewPath, isname);
if (!dini_Exists(file))
{
new name[MAX_PLAYER_NAME], file[256], string[128];
GetPlayerName(playerid, name, sizeof(name));
format(file, sizeof(file), NewPath, name);
dini_Create(file);
dini_IntSet(file, "ClanMember",PlayerInfo[playerid][pClan] = 0);
//format(string, 128, "[SYSTEM]: you have registered with the name %s with password %s.", name, inputtext);
//SendClientMessage(playerid, COLOR_YELLOW, string);
}
if(fexist(file))
{
new name[MAX_PLAYER_NAME], file[256];
GetPlayerName(playerid, name, sizeof(name));
format(file, sizeof(file), NewPath, name);
PlayerInfo[playerid][pClan] = dini_Int(file, "ClanMember");
}
new clanname[24]; // Makes a new string for the name
GetPlayerName(playerid,clanname,sizeof(clanname)); // Assigns it to the name
if(strfind(clanname,"[uLg]",true) != -1) // The != is if it was found.
{
if(PlayerInfo[playerid][pClan] >= 1) // In this case the clan they need to be in is 1
{
// If they are not in the clan then it kicks them.
SendClientMessage(playerid, COLOR_RED, "** Welcome to clan [uLg] **");
return 1;
}
else
{
// If they are then send them a nice welcome message. :)
SendClientMessage(playerid, COLOR_RED, "** You are not in [uLg] clan. Change Your Name Now **");
SetTimerEx("KickClan", 2000, false, "i", playerid);
}
}
return 1;
}
public OnPlayerDisconnect(playerid, reason)
{
new isname[MAX_PLAYER_NAME], file[256];
GetPlayerName(playerid, isname, sizeof(isname));
format(file, sizeof(file), NewPath, isname);
dini_IntSet(file, "ClanMember",PlayerInfo[playerid][pClan]);
return 1;
}
forward KickClan(playerid);
public KickClan(playerid)
{
Kick(playerid);
return 1;
}
CMD:setclanmember(playerid, params[])
{
if(adlvl[playerid] >= 6)
{
new nom [ MAX_PLAYER_NAME ] , str [ 200 ] , pid, option[128];
if(sscanf(params, "us", pid, option))
{
SendClientMessage(playerid, COLOR_YELLOW, "{FFFFFF} /setclanmember [ID] [option]");
SendClientMessage(playerid, COLOR_YELLOW, "{FFFFFF} Options:[0=remove][1=set].");
return 1;
}
if (strcmp(option, "0", true) == 0)
{
GetPlayerName ( playerid , nom , sizeof ( nom ) ) ;
GetPlayerName ( pid , nom , sizeof ( nom ) ) ;
format ( str , sizeof ( str ) , "*You Have Kicked %s From clan member list" , nom ) ;
SendClientMessage ( playerid , 0x00FF00AA , str ) ;
format ( str , sizeof ( str ) , "*Admin %s Has Kick You From [uLg] Clan! Now Remove your [uLg] Tag!" , nom ) ;
SendClientMessage ( playerid , 0x00FF00AA , str ) ;
PlayerInfo[playerid][pClan] = 0 ;
new isname[MAX_PLAYER_NAME], file[256];
GetPlayerName(playerid, isname, sizeof(isname));
format(file, sizeof(file), NewPath, isname);
dini_IntSet(file, "ClanMember",PlayerInfo[playerid][pClan]);
}
if (strcmp(option, "1", true) == 0)
{
GetPlayerName ( playerid , nom , sizeof ( nom ) ) ;
GetPlayerName ( pid , nom , sizeof ( nom ) ) ;
format ( str , sizeof ( str ) , "*You Have Successfuly Set %s As An Clan Member!" , nom ) ;
SendClientMessage ( playerid , 0x00FF00AA , str ) ;
format ( str , sizeof ( str ) , "*%s Has Made You A [uLg] Clan Member! Now You Are Allowed To Use [uLg] Tag in Your Name!" , nom ) ;
SendClientMessage ( playerid , 0x00FF00AA , str ) ;
PlayerInfo[playerid][pClan] = 1 ;
strins(nom,"[uLg]",0,sizeof(nom));
SetPlayerName(pid,nom);
new isname[MAX_PLAYER_NAME], file[256];
GetPlayerName(playerid, isname, sizeof(isname));
format(file, sizeof(file), NewPath, isname);
dini_IntSet(file, "ClanMember",PlayerInfo[playerid][pClan]);
}
}
else return 0;
return 1;
}