APLY-ZONE
Bine ai venit vizitatorule, daca vrei sa ai acces la toate resursele forumului trebuie sa detii un cont. Daca nu detii unul deja iti poti face un cont nou aici : http://aply-zone.tequilaforum.net/register?agreed=true&step=2

Sistem BlackList

In jos

Sistem BlackList

Mesaj Scris de Versus la data de Dum Aug 11, 2013 9:52 am

Salut,
M-am gandit sa va postez un tutorial cu sistemul de BlackList Posted Image

1. Adaugam langa celelalte "forward" urmatorul lucru:

forward SetPlayerUnBlackList();
2. Adaugam langa celelalte "new" urmatorul lucru:

new UnBlackListTimer;
3. Adaugam la "enum pInfo" urmatoarele lucruri:

pBlackList,
pBlackListTime,
4. Adaugam la "public OnPlayerConnect" urmatoarele lucruri:

PlayerInfo[playerid][pBlackList] = 0;
PlayerInfo[playerid][pBlackListTime] = 0;
5. Adaugam la "public SetPlayerUnJail" pe la sfarsit urmatoarele lucruri:

if(PlayerInfo[i][pBlackListTime] > 0)
{
if(PlayerInfo[playerid][pBlackListTime] <= 0)
{
PlayerInfo[playerid][pBlackListTime] = 0;
}
else
{
PlayerInfo[playerid][pBlackListTime] -= 1;
}
}
6. Adaugam la "public GameModeExitFunc" urmatorul lucru:

KillTimer(UnBlackListTimer);
7. Adaugam la "public OnGameModeInit" pe la sfarsit langa celelalte "timer-uri" urmatorul lucru:

UnBlackListTimer = SetTimer("SetPlayerUnBlackList", 1000, 1);
8. Adaugam la "public OnPlayerRegister" langa celelalte urmatoarele lucruri:

format(var, 32, "BlackList=%d\n",PlayerInfo[playerid][pBlackList]);fwrite(hFile, var);
format(var, 32, "BlackListTime=%d\n",PlayerInfo[playerid][pBlackListTime]);fwrite(hFile, var);
9. Adaugam la "public OnPlayerUpdate" langa celelalte urmatoarele lucruri:

format(var, 32, "BlackList=%d\n",PlayerInfo[playerid][pBlackList]);fwrite(hFile, var);
format(var, 32, "BlackListTime=%d\n",PlayerInfo[playerid][pBlackListTime]);fwrite(hFile, var);
10. Adaugam la "public OnPlayerLogin" langa celelalte urmatoarele lucruri:

if( strcmp( key , "BlackList" , true ) == 0 ) { val = ini_GetValue( Data ); PlayerInfo[playerid][pBlackList] = strval( val ); }
if( strcmp( key , "BlackListTime" , true ) == 0 ) { val = ini_GetValue( Data ); PlayerInfo[playerid][pBlackListTime] = strval( val ); }
11. Adaugam la comanda /invite deasupra la "if (gTeam[para1]==TEAM_GREEN && PlayerInfo[para1][pMember] == 0 && PlayerInfo[para1][pFMember] == 255)
{" urmatorul lucru:

if(PlayerInfo[para1][pBlackList] == 1)
{
SendClientMessage(playerid, COLOR_WHITE, "Can't invite him is on the Black List");
return 1;
}
12. Adaugam langa celelalte comenzi urmatoarele comenzi:

if(strcmp(cmd, "/blacklist", true) == 0 || strcmp(cmd, "/bl", true) == 0)
{
if(IsPlayerConnected(playerid))
{
tmp = strtok(cmdtext, idx);
if(!strlen(tmp))
{
SendClientMessage(playerid, COLOR_GREY, "USAGE: /blacklist [playerid/PartOfName] [time(hours)]");
return 1;
}
new playa;
new money;
playa = ReturnUser(tmp);
tmp = strtok(cmdtext, idx);
money = strval(tmp);
if (PlayerInfo[playerid][pAdmin] >= 5 || PlayerInfo[playerid][pLeader] >= 1)
{
if(IsPlayerConnected(playa))
{
if(playa != INVALID_PLAYER_ID)
{
GetPlayerName(playa, giveplayer, sizeof(giveplayer));
GetPlayerName(playerid, sendername, sizeof(sendername));
format(string, sizeof(string), "You Black Listed player %s", giveplayer);
SendClientMessage(playerid, COLOR_LIGHTBLUE, string);
format(string, sizeof(string), "You were Black Listed by Leader %s", sendername);
SendClientMessage(playa, COLOR_LIGHTBLUE, string);
PlayerInfo[playa][pBlackList] = 1;
PlayerInfo[playa][pBlackListTime] = money*3600;
format(string, sizeof(string), "You are Black Listed for %d hours", money);
SendClientMessage(playa, COLOR_LIGHTBLUE, string);
format(string, sizeof(string), "Leader Bot: %s a primit Black List de la %s timp de %d ore", giveplayer, sendername, money);
ABroadCast(COLOR_YELLOW,string,1);
}
}
}
else
{
SendClientMessage(playerid, COLOR_WHITE, "You are not a Leader");
}
}
return 1;
}

if(strcmp(cmd, "/unblacklist", true) == 0 || strcmp(cmd, "/unbl", true) == 0)
{
if(IsPlayerConnected(playerid))
{
tmp = strtok(cmdtext, idx);
if(!strlen(tmp))
{
SendClientMessage(playerid, COLOR_GREY, "USAGE: /unblacklist [playerid/PartOfName]");
return 1;
}
new para1;
para1 = ReturnUser(tmp);
if (PlayerInfo[playerid][pAdmin] >= 5)
{
if(IsPlayerConnected(para1))
{
if(para1 != INVALID_PLAYER_ID)
{
GetPlayerName(para1, giveplayer, sizeof(giveplayer));
GetPlayerName(playerid, sendername, sizeof(sendername));
format(string, sizeof(string), "You UnBlack Listed player %s", giveplayer);
SendClientMessage(playerid, COLOR_LIGHTBLUE, string);
format(string, sizeof(string), "You were UnBlack Listed by Leader %s", sendername);
SendClientMessage(para1, COLOR_LIGHTBLUE, string);
PlayerInfo[para1][pBlackList] = 0;
PlayerInfo[para1][pBlackListTime] = 0;
format(string, sizeof(string), "Leader Bot: %s a primit UnBlack List de la %s", giveplayer, sendername);
ABroadCast(COLOR_YELLOW,string,1);
}
} // Not Connected
}
else
{
SendClientMessage(playerid, COLOR_WHITE, "You are not a Leader");
}
}
return 1;
}

if(strcmp(cmd, "/viewblacklist", true) == 0)
{
if(IsPlayerConnected(playerid))
{
if (PlayerInfo[playerid][pBlackListTime] > 0)
{
new hoursblacklist = PlayerInfo[playerid][pBlackListTime]/3600;
new minutesblacklist = PlayerInfo[playerid][pBlackListTime]/60;
new secondsblacklist = PlayerInfo[playerid][pBlackListTime];
format(string, sizeof(string), "Your Black List will expire in %d Hours (Equivalent: %d Minutes or %d Seconds)", hoursblacklist, minutesblacklist, secondsblacklist);
SendClientMessage(playerid,COLOR_LIGHTBLUE, string);
}
else
{
SendClientMessage(playerid, COLOR_WHITE, "You have not a Black List");
}
}
return 1;
}

if (strcmp(cmd, "/checkblacklist", true) == 0)
{
if(IsPlayerConnected(playerid))
{
if (PlayerInfo[playerid][pAdmin] >= 5 || PlayerInfo[playerid][pLeader] >= 1)
{
tmp = strtok(cmdtext, idx);
if(!strlen(tmp))
{
SendClientMessage(playerid, COLOR_GREY, "USAGE: /checkblacklist [playerid/PartOfName]");
return 1;
}
//giveplayerid = strval(tmp);
giveplayerid = ReturnUser(tmp);
if(IsPlayerConnected(giveplayerid))
{
if(giveplayerid != INVALID_PLAYER_ID)
{
GetPlayerName(giveplayerid, giveplayer, sizeof(giveplayer));
GetPlayerName(playerid, sendername, sizeof(sendername));
new hours = PlayerInfo[giveplayerid][pBlackListTime]/3600;
format(string, sizeof(string), "This player is Black List expires in %d hours", hours);
SendClientMessage(playerid,COLOR_LIGHTBLUE, string);
format(string, sizeof(string), "AdmCmd: %s a primit /checkblacklist de la %s", giveplayer, sendername);
ABroadCast(COLOR_RED,string,1);
}
}
else
{
SendClientMessage(playerid, COLOR_WHITE, "No Such Player");
}
}
else
{
SendClientMessage(playerid, COLOR_WHITE, "You are not a Leader");
}
}
return 1;
}
13. Adaugam pe la sfarsitul GameMode-ului urmatorul lucru:

public SetPlayerUnBlackList()
{
new string[256];
for(new i = 0; i < MAX_PLAYERS; i++)
{
if(IsPlayerConnected(i))
{
if(PlayerInfo[i][pBlackList] > 0)
{
if(PlayerInfo[i][pBlackListTime] > 0)
{
PlayerInfo[i][pBlackListTime]--;
}
if(PlayerInfo[i][pBlackListTime] <= 0)
{
PlayerInfo[i][pBlackListTime] = 0;
if(PlayerInfo[i][pBlackList] == 1)
{
PlayerInfo[i][pBlackList] = 0;
}
PlayerInfo[i][pBlackList] = 0;
SendClientMessage(i, COLOR_WHITE,"Your Black List has ended ! You can now join any faction you want");
format(string, sizeof(string), "~g~Black List Ended~n~~w~Next time respect the faction rules");
GameTextForPlayer(i, string, 5000, 1);
}
}
}
}
}
avatar
Versus
Fondator
Fondator

Mesaje : 151
Puncte : 448
Reputatie : 1
Data de inscriere : 11/08/2013
Localizare : constanta

Vezi profilul utilizatorului

Sus In jos

Re: Sistem BlackList

Mesaj Scris de SPeeDStriKe la data de Mier Aug 14, 2013 1:00 pm

Multumim !
avatar
SPeeDStriKe
Membru
Membru

Mesaje : 913
Puncte : 994
Reputatie : 13
Data de inscriere : 12/08/2013
Varsta : 23
Localizare : Bucuresti

Vezi profilul utilizatorului http://aply-zone.myfreeforum.ro/profile?mode=editprofile

Sus In jos

Sus


 
Permisiunile acestui forum:
Nu puteti raspunde la subiectele acestui forum