Jump to content

Helper


RuSke

Recommended Posts

In acest tutorial va voi arata cum sa adaugam helperi pe server.

In primul rand la functiile definite prin

forward

si adaugam acolo

forward SendHelperMessage(color, string[]);

Apoi mergem la

enum pInfo

si sub

pAdmin,

adaugam

pHelper,

dupa sub

PlayerInfo[playerid][pAdmin] = 0;

adaugam

PlayerInfo[playerid][pHelper] = 0;

apoi la OnPlayerRegister, sub

format(var, 32, "AdminLevel=%d\n",PlayerInfo[playerid][pAdmin]);fwrite(hFile, var);

adaugam

format(var, 32, "HelperLevel=%d\n",PlayerInfo[playerid][pHelper]);fwrite(hFile, var);
apoi la OnPlayerUpdate, sub
format(var, 32, "AdminLevel=%d\n",PlayerInfo[playerid][pAdmin]);fwrite(hFile, var);
adaugam
format(var, 32, "HelperLevel=%d\n",PlayerInfo[playerid][pHelper]);fwrite(hFile, var);
acum sub
if( strcmp( key , "AdminLevel" , true ) == 0 ) { val = ini_GetValue( Data ); PlayerInfo[playerid][pAdmin] = strval( val ); }
Mergem la si definim prin
forward

functia

HBroadCast(color,const string[])

apoi la functiile definite prin

define

scriem:

#define SCM SendClientMessage

acum, la functiile definite prin

public

public HBroadCast(color,const string[])

{

        for(new i = 0; i < MAX_PLAYERS; i++)

        {

                if(IsPlayerConnected(i))

                {

                        if (PlayerInfo[pHelper] != 0)

                        {

                                SCM(i, color, string);

                                printf("%s", string);

                        }

                }

        }

        return 1;

}

Dupa care sub asta definim

SendHelperMessage

si scriem tot la public-uri

public SendHelperMessage(color, string[])

{

        for(new i = 0; i < MAX_PLAYERS; i++)

        {

                if(IsPlayerConnected(i))

                {

                        if(PlayerInfo[pHelper] >= 1)

                        {

                                SendClientMessage(i, color, string);

                        }

                }

        }

}

Apoi facem comenzile, mergem la

OnPlayerCommandText

si sub o comanda adaugam

//------------------------------------------[Helper]-------------------------------------------------------------

        if(strcmp(cmd, "/hc", true) == 0 || strcmp(cmd, "/hchat", true) == 0)

        {

                if(IsPlayerConnected(playerid))

                {

                        GetPlayerName(playerid, sendername, sizeof(sendername));

                        new length = strlen(cmdtext);

                        while ((idx < length) && (cmdtext[idx] <= ' '))

                        {

                                idx++;

                        }

                        new offset = idx;

                        new result[64];

                        while ((idx < length) && ((idx - offset) < (sizeof(result) - 1)))

                        {

                                result[idx - offset] = cmdtext[idx];

                                idx++;

                        }

                        result[idx - offset] = EOS;

                        if(!strlen(result))

                        {

                                SendClientMessage(playerid, COLOR_YELLOW2, "USAGE: (/hchat) [chat]");

                                return 1;

                        }

                        format(string, sizeof(string), "Chat - [Helper] %s : %s **", sendername, result);

                        if (PlayerInfo[playerid][pHelper] >= 1)

                        {

                                SendHelperMessage(COLOR_YELLOW2, string);

                        }

                }

                return 1;

        }

        if(strcmp(cmd, "/hsay", true) == 0)

        {

                if(IsPlayerConnected(playerid))

                {

                        if (PlayerInfo[playerid][pHelper] >= 1)

                        {

                                GetPlayerName(playerid, sendername, sizeof(sendername));

                                new length = strlen(cmdtext);

                                while ((idx < length) && (cmdtext[idx] <= ' '))

                                {

                                        idx++;

                                }

                                new offset = idx;

                                new result[64];

                                while ((idx < length) && ((idx - offset) < (sizeof(result) - 1)))

                                {

                                        result[idx - offset] = cmdtext[idx];

                                        idx++;

                                }

                                result[idx - offset] = EOS;

                                if(!strlen(result))

                                {

                                        SendClientMessage(playerid, COLOR_GRAD2, "USAGE: /hsay [text]");

                                        return 1;

                                }

                                format(string, sizeof(string), "[Helper %s: %s]",sendername,result);

                                for(new i = 0; i < MAX_PLAYERS; i++)

                                {

                                        if(IsPlayerConnected(i))

                                        {

                                                SendClientMessage(i,COLOR_YELLOW2, string);

                                        }

                                }

                                return 1;

                        }

                        else

                        {

                                SendClientMessage(playerid, COLOR_GRAD1, "  you are not authorized to use that command!");

                                return 1;

                        }

                }

                return 1;

        }

                if(strcmp(cmd, "/setint", true) == 0)

        {

                if(IsPlayerConnected(playerid))

                {

                        tmp = strtok(cmdtext, idx);

                        if(!strlen(tmp))

                        {

                                SendClientMessage(playerid, COLOR_GRAD2, "USAGE: /setint [interiorid]");

                                return 1;

                        }

                        new intid;

                        intid = strval(tmp);

                        if (PlayerInfo[playerid][pAdmin] >= 1 || PlayerInfo[playerid][pHelper] >= 1)

                        {

                                SetPlayerInterior(playerid,intid);

                                PlayerInfo[playerid][pInt] = intid;

                                format(string, sizeof(string), "  interiorid %d.", intid);

                                SendClientMessage(playerid, COLOR_GRAD1, string);

                        }

                        else

                        {

                                SendClientMessage(playerid, COLOR_GRAD1, "  You are not authorized to use that command !");

                        }

                }

                return 1;

        }

                if(strcmp(cmd, "/makehelper", true) == 0)

        {

                if(IsPlayerConnected(playerid))

                {

                        tmp = strtok(cmdtext, idx);

                        if(!strlen(tmp))

                        {

                                SCM(playerid, COLOR_GRAD2, "USAGE: /makehelper [playerid/PartOfName] [1-4]");

                                return 1;

                        }

                        new para1;

                        new level;

                        para1 = ReturnUser(tmp);

                        tmp = strtok(cmdtext, idx);

                        level = strval(tmp);

                        if (PlayerInfo[playerid][pAdmin] >= 1337 || PlayerInfo[playerid][pHelper] >= 4)

                        {

                                if(IsPlayerConnected(para1))

                                {

                                        if(para1 != INVALID_PLAYER_ID)

                                        {

                                                GetPlayerName(para1, giveplayer, sizeof(giveplayer));

                                                GetPlayerName(playerid, sendername, sizeof(sendername));

                                                PlayerInfo[para1][pHelper] = level;

                                                printf("News: %s has promoted %s to a level %d helper.", sendername, giveplayer, level);

                                                format(string, sizeof(string), "  You have been promoted to a level %d helper by %s", level, sendername);

                                                SCM(para1, COLOR_LIGHTBLUE, string);

                                                format(string, sizeof(string), "  You have promoted %s to a level %d helper.", giveplayer,level);

                                                SCM(playerid, COLOR_LIGHTBLUE, string);

                                                format(string, 256, "News: %s has set %s to a level %d helper.", sendername,giveplayer,level);

                                                ABroadCast(COLOR_YELLOW,string,1);

                                        }

                                }

                        }

                        else

                        {

                                SCM(playerid, COLOR_GRAD1, "  you are not authorized to use that command!");

                        }

                }

                return 1;

        }

                if (strcmp(cmd, "/helpers", true) == 0)

          {

                new counth = 0;

                SCM(playerid, 0xCCD802AA, "[____________Helpers Online___________]");

                for(new i = 0; i < MAX_PLAYERS; i++)

                {

                        if (IsPlayerConnected(i))

                        {

                                if(PlayerInfo[pHelper] == 1)

                                {

                                        GetPlayerName(i, sendername, sizeof(sendername));

                                        format(string, 256, "Helper Level 1 : %s ", sendername);

                                        SCM(playerid,0xCAFF70AA, string);

                                        counth++;

                                }

                                                        if(PlayerInfo[pHelper] == 2)

                                {

                                        GetPlayerName(i, sendername, sizeof(sendername));

                                        format(string, 256, "Helper Level 2 : %s ", sendername);

                                        SCM(playerid,0x1E90FFAA, string);

                                        counth++;

                                }

                                                        if(PlayerInfo[pHelper] == 3)

                                {

                                        GetPlayerName(i, sendername, sizeof(sendername));

                                        format(string, 256, "Helper Level 3 : %s ", sendername);

                                        SCM(playerid,0xFFDEADAA, string);

                                        counth++;

                                }

                        }

                }

                if (counth == 0)

                SCM(playerid,COLOR_LIGHTRED,"No Helpers online on the server");

                SCM(playerid,0xCCD802AA, "[____________________________________]");

                return 1;

          }

          if(strcmp(cmd, "/hhelp", true) == 0 || strcmp(cmd, "/hh", true) == 0)

        {

                if(IsPlayerConnected(playerid))

                {

                        SendClientMessage(playerid, 0x33CCFFAA,"|___________________________________________[Helper Commands]_____________________________________|");

                        if (PlayerInfo[playerid][pHelper] >= 1)

                        {

                                SendClientMessage(playerid, COLOR_GREEN, "[Helper Level 1] /respawn /check /setint /mute /goto /cc (nu abuzati) /slap /hc  ( helper chat )");

                        }

                        if (PlayerInfo[playerid][pHelper] >= 2)

                        {

                                SendClientMessage(playerid, COLOR_LIGHTRED,"[Helper Level 2] /gotosf /gotols /gotog /gotom /hsay ");

                        }

                        if (PlayerInfo[playerid][pHelper] >= 3)

                        {

                                SendClientMessage(playerid, COLOR_YELLOW2,"[Helper Level 3] /gethere /agl ");

                        }

                        if (PlayerInfo[playerid][pHelper] >= 4)

                        {

                                SendClientMessage(playerid, COLOR_LIGHTBLUE,"[Helper Level 4] /makehelper ");

                        }

                        SendClientMessage(playerid, 0x33CCFFAA,"|__________________________________________[Helper Commands]________________________________________|");

                }

                return 1;

        }

                if(strcmp(cmd, "/needhelp", true) == 0)

        {

                if(IsPlayerConnected(playerid))

                {

                        if(PlayerInfo[playerid][pHMuted] == 1)

                        {

                                SendClientMessage(playerid, TEAM_CYAN_COLOR, "  You can't speak, you have been silenced !");

                                return 1;

                        }

                        GetPlayerName(playerid, sendername, sizeof(sendername));

                        new length = strlen(cmdtext);

                        while ((idx < length) && (cmdtext[idx] <= ' '))

                        {

                                idx++;

                        }

                        new offset = idx;

                        new result[64];

                        while ((idx < length) && ((idx - offset) < (sizeof(result) - 1)))

                        {

                                result[idx - offset] = cmdtext[idx];

                                idx++;

                        }

                        result[idx - offset] = EOS;

                        if(!strlen(result))

                        {

                                SendClientMessage(playerid, COLOR_GRAD2, "USAGE: /needhelp [text]");

                                return 1;

                        }

                        format(string, sizeof(string), "Help requested from %s : %s", sendername, (result));

                        HBroadCast(COLOR_YELLOW,string);

                        SendClientMessage(playerid, COLOR_YELLOW, "Your help request has been sent, please wait for a answer.");

                }

                return 1;

        }

Acum cautam comanda

/goto

si o schimbam cu

if(strcmp(cmd, "/goto", true) == 0)

        {

                if(IsPlayerConnected(playerid))

                {

                        tmp = strtok(cmdtext, idx);

                        if(!strlen(tmp))

                        {

                                SendClientMessage(playerid, COLOR_GRAD2, "USAGE: /goto [playerid/PartOfName]");

                                return 1;

                        }

                        new Float:plocx,Float:plocy,Float:plocz;

                        new plo;

                        plo = ReturnUser(tmp);

                        if (IsPlayerConnected(plo))

                        {

                                if(plo != INVALID_PLAYER_ID)

                                {

                                        if (PlayerInfo[playerid][pAdmin] >= 1 || PlayerInfo[playerid][pHelper] >= 1)

                                        {

                                                if(Spectate[playerid] != 255)

                                                {

                                                        Spectate[playerid] = 256;

                                                }

                                                GetPlayerPos(plo, plocx, plocy, plocz);

                                                if(PlayerInfo[plo][pInt] > 0)

                                                {

                                                        SetPlayerInterior(playerid,PlayerInfo[plo][pInt]);

                                                        PlayerInfo[playerid][pInt] = PlayerInfo[plo][pInt];

                                                        PlayerInfo[playerid][pLocal] = PlayerInfo[plo][pLocal];

                                                }

                                                if(PlayerInfo[playerid][pInt] == 0)

                                                {

                                                        SetPlayerInterior(playerid,0);

                                                }

                                                if(plocz > 530.0 && PlayerInfo[plo][pInt] == 0) //the highest land point in sa = 526.8

                                                {

                                                        SetPlayerInterior(playerid,1);

                                                        PlayerInfo[playerid][pInt] = 1;

                                                }

                                                if (GetPlayerState(playerid) == 2)

                                                {

                                                        new tmpcar = GetPlayerVehicleID(playerid);

                                                        SetVehiclePos(tmpcar, plocx, plocy+4, plocz);

                                                        TelePos[playerid][0] = 0.0;TelePos[playerid][1] = 0.0;

                                                }

                                                else

                                                {

                                                        SetPlayerPos(playerid,plocx,plocy+2, plocz);

                                                }

                                                SendClientMessage(playerid, COLOR_GRAD1, "  You have been teleported");

                                        }

                                        else

                                        {

                                                SendClientMessage(playerid, COLOR_GRAD1, "  you are not authorized to use that command!");

                                        }

                                }

                        }

                        else

                        {

                                format(string, sizeof(string), " That player is not connected.", plo);

                                SendClientMessage(playerid, COLOR_GRAD1, string);

                        }

                }

                return 1;

        }

ACEST TUTORIAL ESTE FACUT DE MINE SI UN PRIETEN.

Si asta a fost tot, sper sa va fie de folos, daca intampinati probleme postati aici.

HostName: [~Romania~]*StyleClub Role-Play România

Address:  89.35.18.11:7777

Mode:     RolePlay v4.8G

Link to comment
Share on other sites

! Acest 2xPost este corect pentru ca este la un interval de peste 24 de ore.

ACEST TUTORIAL ESTE FACUT DE MINE SI UN PRIETEN.

Mi s-a raportat + dat link de la postul original de la alt forum, acolo era postat pe data de 23 Iunie 2010, si aici pe 1 decembrie 2011, copiat 100%.

A treia greseala de acest tip din partea lui RusKe, muted.

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. For more details you can also review our Terms of Use and Privacy Policy.