[Tutorial]Schimbare Sistem PayDay
:: Ro-SAMP | Servicii :: Tutoriale :: Tutoriale SA:MP
Pagina 1 din 1
[Tutorial]Schimbare Sistem PayDay
Salut. In acest tutorial am sa va arat sistemul meu payday mai avansat ( seamana cu cel actual al eGaming-ului ). Am vazut ca multi ati postat ca vreti acest sistem, asa ca m-am decis sa va arat pas cu pas ce trebuie sa faceti + sa intelegeti cum functioneaza.
Inainte sa incepem, avem cerintele pentru a urmarii acest tutorial:
-Sa ai cel putin 16 ani ca sa intelegi macar limbajul de programare
-Sa stii cu ce se papa scriptingul si mai ales pawno
-Sa fii atent la fiecare pas
Pasul 1
Primul lucru pe care trebuie sa il faceti este sa adaugati aceasta variabila, pday langa celelalte de la pinfo
enum pInfo
{
////
pDay,
};
new PlayerInfo[MAX_PLAYERS][pInfo];
Pasul 2
Acum va trebuie sa stocam aceasta data, o vom salva si desigur o vom incarca cand jucatorul va intra pe server
Adaugam langa celelalte la OnPlayerRegister
format(var, 32, "pDay=%d\n",PlayerInfo[playerid][pDay]);fwrite(hFile, var);
Pentru a salva adaugam langa celelalte la SavePlayerData
format(var, 32, "pDay=%d\n",PlayerInfo[playerid][pDay]);fwrite(hFile, var);
Iar cand jucatorul intra pe server, adaugam langa celelalte la OnPlayerLogin
if( strcmp( key , "pDay" , true ) == 0 ) { val = ini_GetValue( Data ); PlayerInfo[playerid][pDay] = strval( val ); }
Pasul 3
In acest pas trebuie sa determinam timpul pe care trebuie sa il indeplineasca utilizatorul pt a lua paycheck
Mergem la OnPlayerConnect si adaugam jos de tot langa celelalte
PlayerInfo[playerid][pDay] = 3600; // 3600 inseamna o ora in secunde
Pasul 4
Ca sa creeam timpul scurs trebuie sa adaugam urmatorul cod la public OtherTime
if(PlayerInfo[i][pDay] >= 0)
{
PlayerInfo[i][pDay]--;
if(PlayerInfo[i][pDay] <= 0)
{
PlayerInfo[i][pDay] = 3600;
PayDay();
}
}
Pasul 5
Aici am creeat special comanda pentru acest sistem, deci toate creditele imi vin mie
CMD:pday(playerid, params[])
{
if(gPlayerLogged[playerid] == 0) return SendClientMessage(playerid, COLOR_GRAD1, "You havent logged in yet !");
new ttext[20];
if(PlayerInfo[playerid][pMember] == 4 || PlayerInfo[playerid][pLeader] == 4) { ttext = "Medic"; }
else if(gTeam[playerid] == 3) { ttext = "Civilian"; }
else if(PlayerInfo[playerid][pMember] == 1 || PlayerInfo[playerid][pLeader] == 1) { ttext = "Police Departament"; }
else if(PlayerInfo[playerid][pMember] == 2 || PlayerInfo[playerid][pLeader] == 2) { ttext = "FBI Agent"; }
else if(PlayerInfo[playerid][pMember] == 3 || PlayerInfo[playerid][pLeader] == 3) { ttext = "National Guard"; }
else if(PlayerInfo[playerid][pMember] == 4 || PlayerInfo[playerid][pLeader] == 4) { ttext = "Firemen/Paramedic"; }
else if(PlayerInfo[playerid][pMember] == 5 || PlayerInfo[playerid][pLeader] == 5) { ttext = "LCN"; }
else if(PlayerInfo[playerid][pMember] == 6 || PlayerInfo[playerid][pLeader] == 6) { ttext = "Yakuza"; }
else if(PlayerInfo[playerid][pMember] == 8 || PlayerInfo[playerid][pLeader] == { ttext = "Hitmen"; }
else if(PlayerInfo[playerid][pMember] == 9 || PlayerInfo[playerid][pLeader] == 9) { ttext = "News Reporter"; }
else if(PlayerInfo[playerid][pMember] == 10 || PlayerInfo[playerid][pLeader] == 10) { ttext = "Taxi"; }
else if(PlayerInfo[playerid][pMember] == 11 || PlayerInfo[playerid][pLeader] == 11) { ttext = "FMA"; }
else if(PlayerInfo[playerid][pMember] == 12 || PlayerInfo[playerid][pLeader] == 12) { ttext = "Crips Gang"; }
else if(PlayerInfo[playerid][pMember] == 13 || PlayerInfo[playerid][pLeader] == 13) { ttext = "Bloods Gang"; }
else if(PlayerInfo[playerid][pMember] == 14 || PlayerInfo[playerid][pLeader] == 14) { ttext = "Surenos Gang"; }
else if(PlayerInfo[playerid][pMember] == 15 || PlayerInfo[playerid][pLeader] == 15) { ttext = "Nortenos Gang"; }
new coordsstring[256];
new plevel = PlayerInfo[playerid][pLevel];
new ptime = PlayerInfo[playerid][pConnectTime];
new pday = PlayerInfo[playerid][pDay];
new name[MAX_PLAYER_NAME];
GetPlayerName(playerid, name, sizeof(name));
SendClientMessage(playerid, COLOR_GREEN,"________________________________________________________________________________________");
format(coordsstring, sizeof(coordsstring)," xxx [ %s - Level %d, %s] xxx",name,plevel,ttext);
SendClientMessage(playerid, COLOR_LIGHTGREEN,coordsstring);
format(coordsstring, sizeof(coordsstring),"» NextPay [%d] OnlineHours [%d]",pday/60,ptime);
SendClientMessage(playerid, 0xCFCFCFFF,coordsstring);
SendClientMessage(playerid, COLOR_GREEN,"________________________________________________________________________________________");
return 1;
}
Pasul 6
Aici trebuie sa eliminati payday-ul anterior care va venea la si fix, cum faceti asta ? Simplu, inlocuiti SyncTime cu acesta de mai jos
public SyncTime()
{
new string[64];
new tmphour;
new tmpminute;
new tmpsecond;
gettime(tmphour, tmpminute, tmpsecond);
FixHour(tmphour);
tmphour = shifthour;
if ((tmphour > ghour) || (tmphour == 0 && ghour == 23))
{
format(string, sizeof(string), "SERVER: The time is now %d:00 hours",tmphour+1);
BroadCast(COLOR_WHITE,string);
ghour = tmphour;
if (realtime)
{
SetWorldTime(tmphour);
}
}
}
Si cam asta a fost totul, daca ati urmarit cu atentie toate pasurile sunt sigur ca acest sistem va functiona perfect.
Inainte sa incepem, avem cerintele pentru a urmarii acest tutorial:
-Sa ai cel putin 16 ani ca sa intelegi macar limbajul de programare
-Sa stii cu ce se papa scriptingul si mai ales pawno
-Sa fii atent la fiecare pas
Pasul 1
Primul lucru pe care trebuie sa il faceti este sa adaugati aceasta variabila, pday langa celelalte de la pinfo
enum pInfo
{
////
pDay,
};
new PlayerInfo[MAX_PLAYERS][pInfo];
Pasul 2
Acum va trebuie sa stocam aceasta data, o vom salva si desigur o vom incarca cand jucatorul va intra pe server
Adaugam langa celelalte la OnPlayerRegister
format(var, 32, "pDay=%d\n",PlayerInfo[playerid][pDay]);fwrite(hFile, var);
Pentru a salva adaugam langa celelalte la SavePlayerData
format(var, 32, "pDay=%d\n",PlayerInfo[playerid][pDay]);fwrite(hFile, var);
Iar cand jucatorul intra pe server, adaugam langa celelalte la OnPlayerLogin
if( strcmp( key , "pDay" , true ) == 0 ) { val = ini_GetValue( Data ); PlayerInfo[playerid][pDay] = strval( val ); }
Pasul 3
In acest pas trebuie sa determinam timpul pe care trebuie sa il indeplineasca utilizatorul pt a lua paycheck
Mergem la OnPlayerConnect si adaugam jos de tot langa celelalte
PlayerInfo[playerid][pDay] = 3600; // 3600 inseamna o ora in secunde
Pasul 4
Ca sa creeam timpul scurs trebuie sa adaugam urmatorul cod la public OtherTime
if(PlayerInfo[i][pDay] >= 0)
{
PlayerInfo[i][pDay]--;
if(PlayerInfo[i][pDay] <= 0)
{
PlayerInfo[i][pDay] = 3600;
PayDay();
}
}
Pasul 5
Aici am creeat special comanda pentru acest sistem, deci toate creditele imi vin mie
CMD:pday(playerid, params[])
{
if(gPlayerLogged[playerid] == 0) return SendClientMessage(playerid, COLOR_GRAD1, "You havent logged in yet !");
new ttext[20];
if(PlayerInfo[playerid][pMember] == 4 || PlayerInfo[playerid][pLeader] == 4) { ttext = "Medic"; }
else if(gTeam[playerid] == 3) { ttext = "Civilian"; }
else if(PlayerInfo[playerid][pMember] == 1 || PlayerInfo[playerid][pLeader] == 1) { ttext = "Police Departament"; }
else if(PlayerInfo[playerid][pMember] == 2 || PlayerInfo[playerid][pLeader] == 2) { ttext = "FBI Agent"; }
else if(PlayerInfo[playerid][pMember] == 3 || PlayerInfo[playerid][pLeader] == 3) { ttext = "National Guard"; }
else if(PlayerInfo[playerid][pMember] == 4 || PlayerInfo[playerid][pLeader] == 4) { ttext = "Firemen/Paramedic"; }
else if(PlayerInfo[playerid][pMember] == 5 || PlayerInfo[playerid][pLeader] == 5) { ttext = "LCN"; }
else if(PlayerInfo[playerid][pMember] == 6 || PlayerInfo[playerid][pLeader] == 6) { ttext = "Yakuza"; }
else if(PlayerInfo[playerid][pMember] == 8 || PlayerInfo[playerid][pLeader] == { ttext = "Hitmen"; }
else if(PlayerInfo[playerid][pMember] == 9 || PlayerInfo[playerid][pLeader] == 9) { ttext = "News Reporter"; }
else if(PlayerInfo[playerid][pMember] == 10 || PlayerInfo[playerid][pLeader] == 10) { ttext = "Taxi"; }
else if(PlayerInfo[playerid][pMember] == 11 || PlayerInfo[playerid][pLeader] == 11) { ttext = "FMA"; }
else if(PlayerInfo[playerid][pMember] == 12 || PlayerInfo[playerid][pLeader] == 12) { ttext = "Crips Gang"; }
else if(PlayerInfo[playerid][pMember] == 13 || PlayerInfo[playerid][pLeader] == 13) { ttext = "Bloods Gang"; }
else if(PlayerInfo[playerid][pMember] == 14 || PlayerInfo[playerid][pLeader] == 14) { ttext = "Surenos Gang"; }
else if(PlayerInfo[playerid][pMember] == 15 || PlayerInfo[playerid][pLeader] == 15) { ttext = "Nortenos Gang"; }
new coordsstring[256];
new plevel = PlayerInfo[playerid][pLevel];
new ptime = PlayerInfo[playerid][pConnectTime];
new pday = PlayerInfo[playerid][pDay];
new name[MAX_PLAYER_NAME];
GetPlayerName(playerid, name, sizeof(name));
SendClientMessage(playerid, COLOR_GREEN,"________________________________________________________________________________________");
format(coordsstring, sizeof(coordsstring)," xxx [ %s - Level %d, %s] xxx",name,plevel,ttext);
SendClientMessage(playerid, COLOR_LIGHTGREEN,coordsstring);
format(coordsstring, sizeof(coordsstring),"» NextPay [%d] OnlineHours [%d]",pday/60,ptime);
SendClientMessage(playerid, 0xCFCFCFFF,coordsstring);
SendClientMessage(playerid, COLOR_GREEN,"________________________________________________________________________________________");
return 1;
}
Pasul 6
Aici trebuie sa eliminati payday-ul anterior care va venea la si fix, cum faceti asta ? Simplu, inlocuiti SyncTime cu acesta de mai jos
public SyncTime()
{
new string[64];
new tmphour;
new tmpminute;
new tmpsecond;
gettime(tmphour, tmpminute, tmpsecond);
FixHour(tmphour);
tmphour = shifthour;
if ((tmphour > ghour) || (tmphour == 0 && ghour == 23))
{
format(string, sizeof(string), "SERVER: The time is now %d:00 hours",tmphour+1);
BroadCast(COLOR_WHITE,string);
ghour = tmphour;
if (realtime)
{
SetWorldTime(tmphour);
}
}
}
Si cam asta a fost totul, daca ati urmarit cu atentie toate pasurile sunt sigur ca acest sistem va functiona perfect.
master_all- Expert
- Mesaje : 324
Data de inscriere : 06/11/2012
Subiecte similare
» [Tutorial] Cum sa faci un sistem de logare/inregistrare!
» [Tutorial] Crearea factiunilor !
» TUTORIAL: Cum sa schimbi culoarea ochilor !
» [Tutorial] Crearea factiunilor !
» TUTORIAL: Cum sa schimbi culoarea ochilor !
:: Ro-SAMP | Servicii :: Tutoriale :: Tutoriale SA:MP
Pagina 1 din 1
Permisiunile acestui forum:
Nu puteti raspunde la subiectele acestui forum