P-GaMinG CommuniTy
Welcome To Community!


Welcome To GaMinG
 
HomeCalendarFAQSearchMemberlistUsergroupsRegisterLog in

Share | 
 

 Adaugare Helpers

Go down 
AuthorMessage
cristian
Admin
avatar

Mesaje : 109
Data de inscriere : 2011-03-12
Varsta : 22
Localizare : Buzau

PostSubject: Adaugare Helpers    Sat Mar 12, 2011 9:09 am

Adaugare Helpers
In acest tutorial va voi arata cum sa adaugam helperi pe server.
In primul rand la functiile definite prin


Cod:
forward



si adaugam acolo


Cod:
forward SendHelperMessage(color, string[]);




Apoi mergem la


Cod:
enum pInfo



si sub


Cod:
pAdmin,



adaugam


Cod:
pHelper,




, dupa sub


Cod:
PlayerInfo[playerid][pAdmin] = 0;



adaugam


Cod:
PlayerInfo[playerid][pHelper] = 0;




apoi la OnPlayerRegister, sub


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



adaugam


Cod:
format(var, 32, "HelperLevel=%d\n",PlayerInfo[playerid][pHelper]);fwrite(hFile, var);




apoi la OnPlayerUpdate, sub


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



adaugam


Cod:
format(var, 32, "HelperLevel=%d\n",PlayerInfo[playerid][pHelper]);fwrite(hFile, var);




acum sub


Cod:
if( strcmp( key , "AdminLevel" , true ) == 0 ) { val = ini_GetValue( Data ); PlayerInfo[playerid][pAdmin] = strval( val ); }



adaugam


Cod:
if( strcmp( key , "HelperLevel" , true ) == 0 ) { val = ini_GetValue( Data ); PlayerInfo[playerid][pHelper] = strval( val ); }




Mergem la si definim prin


Cod:
forward



functia


Cod:
HBroadCast(color,const string[])




, apoi la functiile definite prin


Cod:
define



scriem


Cod:
#define SCM SendClientMessage




acum, la functiile definite prin


Cod:
public



adaugam


Cod:
public HBroadCast(color,const string[])
{
for(new i = 0; i < MAX_PLAYERS; i++)
{
if(IsPlayerConnected(i))
{
if (PlayerInfo[i][pHelper] != 0)
{
SCM(i, color, string);
printf("%s", string);
}
}
}
return 1;
}



Dupa care sub asta definim


Cod:
SendHelperMessage



si scriem tot la public-uri


Cod:
public SendHelperMessage(color, string[])
{
for(new i = 0; i < MAX_PLAYERS; i++)
{
if(IsPlayerConnected(i))
{
if(PlayerInfo[i][pHelper] >= 1)
{
SendClientMessage(i, color, string);
}
}
}
}




Apoi facem comenzile, mergem la


Cod:
OnPlayerCommandText



si sub o comanda adaugam


Cod:
//------------------------------------------[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[i][pHelper] == 1)
{
GetPlayerName(i, sendername, sizeof(sendername));
format(string, 256, "Helper Level 1 : %s ", sendername);
SCM(playerid,0xCAFF70AA, string);
counth++;
}
if(PlayerInfo[i][pHelper] == 2)
{
GetPlayerName(i, sendername, sizeof(sendername));
format(string, 256, "Helper Level 2 : %s ", sendername);
SCM(playerid,0x1E90FFAA, string);
counth++;
}
if(PlayerInfo[i][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


Cod:
/goto



si o schimbam cu


Cod:
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;
}



Si asta a fost tot, sper sa va fie de folos, daca intampinati probleme postati
Back to top Go down
View user profile http://p-games.formyjob.net
 
Adaugare Helpers
Back to top 
Page 1 of 1

Permissions in this forum:You cannot reply to topics in this forum
P-GaMinG CommuniTy :: P-gaming - SA:MP :: Tutoriale-
Jump to: