Public.CSArenaX.Ro // mentenanta 193.84.64.58:27015
CSArenaX RPG | Joi 28.02 ora: 18:00 deschiderea | 89.34.24.180:7777

Toate drepturile rezervate! Copyright by CSArenaX.Ro

Sign in to follow this  
Followers 0
Ionut Faraon

[Tutoral/SA:MP] Schimbare sistem payday

2 posts in this topic

Introducere :
 

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[pDay] >= 0)
{
PlayerInfo[pDay]--;
if(PlayerInfo[pDay] <= 0)
{
    PlayerInfo[pDay] = 3600;
    PayDay();
}
}
Pasul 5
 
Aici am creeat special comanda pentru acest sistem, deci toate creditele imi vin mie biggrin.png
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] == 8) { 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);
}
}
}

Share this post


Link to post
Share on other sites
Guest
This topic is now closed to further replies.
Sign in to follow this  
Followers 0