Sistem AFK si Back - Forum

[ Mesaje noi · Membrii · Regulamentul forumului · Căutare · RSS ]
Pagina 1 din 11
Forum » Tutoriale si Resurse (T&R) » T&R SA-MP » Sistem AFK si Back ([Tutorial])
Sistem AFK si Back
GravediggerData: Vineri, 2012-12-14, 7:10 PM | Mesaj # 1
Gravedigger
Administrator
Grup: Administratori
Mesaje: 542
Premii: 10
Reputatie: 5
Stare: Offline


Mai intai sa va explic ce inseamna Afk si Back.Atunci cand un player sta nemiscat o anumita periada de timp ceilalti jucatori nu vor mai putea sa il atace iar apoi cand incepe sa se deplaseze sa il poti ataca.Acest sistem este bun atunci cand un anumit jucator pleaca de la calculator si nu vrea sa fie atacat de ceilalti.

Sa incepem:

Pasul 1: La inceput gm-ului adaugam:
Cod
new afk[MAX_PLAYERS];


Pasul 2: Cautam in GM linia public OnPlayerConnect(playerid)
Cod
afk [playerid]= 0;


Pasul 3: Cautam in GM linia public OnPlayerCommand
Aici trebuie sa adaugam trei comenzi /afk /back /afklist

Comanda /afk:
Cod
if(strcmp(cmd, "/afk", true) == 0)     
{     
if(afk [playerid]== 0)     
{     
afk [playerid]= 1;     
SetPlayerColor(playerid,0x737373FF);     
TogglePlayerControllable(playerid,0);     
GetPlayerName(playerid, sendername, 24);     
format(string, 256, "%s is away from keyboard.", sendername);     
ProxDetector(20.0, playerid, string, 0xC2A2DAAA, 0xC2A2DAAA, 0xC2A2DAAA, 0xC2A2DAAA, 0xC2A2DAAA);     
}     
return 1;     
}     

[color=yellow]Comanda /back:[/color]
Code:     
if(strcmp(cmd, "/back", true) == 0)     
{     
if(afk [playerid]== 1)     
{     
afk [playerid]= 0;     
SetPlayerToTeamColor(playerid);     
TogglePlayerControllable(playerid,1);     
GetPlayerName(playerid, sendername, 24);     
format(string, 256, "%s is no more away from keyboard.", sendername);     
ProxDetector(20.0, playerid, string, 0xC2A2DAAA, 0xC2A2DAAA, 0xC2A2DAAA, 0xC2A2DAAA, 0xC2A2DAAA);     
}     
return 1;     
}


Comanda /afklist:
Cod
if (strcmp("/afklist", cmdtext, true, 7) == 0)     
{     
SendClientMessage(playerid, COLOR_YELLOW, ".:: AFK Players ::. ");     
for(new i = 0; i < MAX_PLAYERS; i++)     
{     
if(IsPlayerConnected(i))     
{     
if(afk [playerid]== 1)     
{     
new name[128];     
GetPlayerName(i, name, MAX_PLAYER_NAME);     
format(string, 256, "Player: \"%s\" | ID: %d", name, i);     
SendClientMessage(playerid, COLOR_YELLOW, string);     
}     
}     
}     
return 1;     
}

 
Forum » Tutoriale si Resurse (T&R) » T&R SA-MP » Sistem AFK si Back ([Tutorial])
Pagina 1 din 11
Căutare: