04.11.2011, 02:34
Bem tenho um sistema de helper e queria que ele tivesse salvamento dos helper pq n esta salvando...
O code й esse:
O code й esse:
pawn Код:
//===========================By:Scorpion_King=============== Nгo Retire os Creditos
#include <a_samp>
#include <utils>
#define COLOR_GRAD1 0xB4B5B7FF
#define COLOR_GRAD2 0xBFC0C2FF
#define COLOR_GREY 0xAFAFAFAA
#define COLOR_ORANGE 0xFF9900AA
#define COLOR_WHITE 0xFFFFFFAA
#define COLOR_HELPER 0x00D087AA
#define KB "{FFFF00}" //Ken & Bruno red
#define KG "{33FF00}" //Ken & Bruno Green
#define KR "{FF0000}" //Ken & Bruno Red
#define KY "{FF4500}" //Ken & Bruno Yellow
#define Kz "{00FF00}" //Ken & Bruno Yw
#define KM "{0000FF}" //Ken & Bruno Yo
#define KN "{FF00FF}" //rOSA
#define KD "{FFFFFF}" // detran
forward SendHelperMessage(color, string[]);
forward SendHelperAdminMessage(color, string[]);
new anhelper[MAX_PLAYERS];
new meavaliehelper[MAX_PLAYERS];
new meavalie[MAX_PLAYERS];
new clickplay[MAX_PLAYERS];
forward TempoAnHelper(playerid);
forward TempoAvalieHelper(playerid);
#define DIALOG_MEAVALIE 100
#define DIALOG_HELPER 101
#define DIALOG_PAR 102
#define TEMPO_AN 900000 // 15 minutos
#define TEMPO_MEAVALIE 900000 //15 minutos
enum pInfo
{
pAdmin,
pHelper,
pHelperTrabalhando
};
new PlayerInfo[MAX_PLAYERS][pInfo];
#if defined FILTERSCRIPT
public OnFilterScriptInit()
{
print("\n----------------------------------");
print(" sistema de Helpers por Scorpion_King");
print("----------------------------------\n");
return 1;
}
public OnFilterScriptExit()
{
return 1;
}
#else
main()
{
print("\n----------------------------------");
print(" sistema de Helpers por Scorpion_King");
print("----------------------------------\n");
}
#endif
public OnPlayerConnect(playerid)
{
PlayerInfo[playerid][pHelper] = 0;
PlayerInfo[playerid][pHelperTrabalhando] = 0;
return 1;
}
public OnPlayerDisconnect(playerid, reason)
{
return PlayerInfo[playerid][pHelperTrabalhando] = 0;
}
public OnPlayerCommandText(playerid, cmdtext[])
{
new sendername[MAX_PLAYER_NAME];
GetPlayerName(playerid, sendername, sizeof(sendername));
new giveplayer[MAX_PLAYER_NAME];
new cmd[128];
new tmp[128];
//new giveplayerid, idx;
new idx;
new string[128];
cmd = strtok(cmdtext, idx); // adicione isso.
if (strcmp(cmd, "/helperes", true) == 0)
{
SendClientMessage(playerid, COLOR_GREY, "||--||--|| Helpers Online ||--||--||");
for(new i = 0; i <= MAX_PLAYERS; i++)
{
if(IsPlayerConnected(i) == 1 && PlayerInfo[i][pHelper] > 0)
{
if(PlayerInfo[i][pHelperTrabalhando] == 1)
{
GetPlayerName(i, sendername, sizeof(sendername));
if(PlayerInfo[i][pHelper] == 1)
{
format(string, 256, "{FFFFFF}Nome:{FFFF00} %s {FFFFFF}[{FF4500}}Helper{FFFFFF}] {FFFFFF}({33FF00}Trabalhando{FFFFFF})", sendername);
SendClientMessage(playerid, COLOR_HELPER, string);
}
if(PlayerInfo[i][pHelper] >= 25)
{
format(string, 256, "{FFFFFF}Nome: %s {FFFFFF}[{FF4500}Helper{FFFFFF}] {FFFFFF}({33FF00}Trabalhando{FFFFFF})", sendername);
SendClientMessage(playerid, COLOR_HELPER, string);
}
if(PlayerInfo[i][pHelper] >= 50)
{
format(string, 256, "{FFFFFF}Nome: %s {FFFFFF}[{FF4500}Helper Master{FFFFFF}] {FFFFFF}({33FF00}Trabalhando{FFFFFF})", sendername);
SendClientMessage(playerid, COLOR_HELPER, string);
}
if(PlayerInfo[i][pHelper] >= 100)
{
format(string, 256, "{FFFFFF}Nome: %s {FFFFFF}[{FF4500}Super Helper{FFFFFF}] {FFFFFF}({33FF00}Trabalhando{FFFFFF})", sendername);
SendClientMessage(playerid, COLOR_HELPER, string);
}
}
else
{
GetPlayerName(i, sendername, sizeof(sendername));
if(PlayerInfo[i][pHelper] == 1)
{
format(string, 256, "{FFFFFF}Nome: %s {FFFFFF}[{FF4500}Helper{FFFFFF}] {FFFFFF}({FFFF00}Jogando{FFFFFF})", sendername);
SendClientMessage(playerid, COLOR_HELPER, string);
}
if(PlayerInfo[i][pHelper] >= 25)
{
format(string, 256, "{FFFFFF}Nome: %s {FFFFFF}[{FF4500}Helper{FFFFFF}] {FFFFFF}({FFFF00}Jogando)", sendername);
SendClientMessage(playerid, COLOR_HELPER, string);
}
if(PlayerInfo[i][pHelper] >= 50)
{
format(string, 256, "{FFFFFF}Nome: %s {FFFFFF}[{FF4500}Helper Master{FFFFFF}] {FFFFFF}({FFFF00}Jogando)", sendername);
SendClientMessage(playerid, COLOR_HELPER, string);
}
if(PlayerInfo[i][pHelper] >= 100)
{
format(string, 256, "{FFFFFF}Nome: %s {FFFFFF}[{FF4500}Super Helper{FFFFFF}] {FFFFFF}({FFFF00}Jogando{FFFFFF})", sendername);
SendClientMessage(playerid, COLOR_HELPER, string);
}
}
}
}
return 1;
}
if(strcmp(cmd, "/avisohelper", true) == 0 || strcmp(cmd, "/avh", true) == 0)
{
if(IsPlayerConnected(playerid))
{
new length = strlen(cmdtext);
while ((idx < length) && (cmdtext[idx] <= ' '))
{
idx++;
}
new offset = idx;
new result[128];
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, "USE: (/[av]iso[h]elper) [mensagem]");
return 1;
}
if(PlayerInfo[playerid][pHelperTrabalhando] == 0)
{
return SendClientMessage(playerid,COLOR_GRAD2,"Vocк nгo estб em trabalho!Use: /ha");
}
if(PlayerInfo[playerid][pHelper] < 2)
{
return SendClientMessage(playerid,COLOR_GRAD1,"Vocк nгo tem autorizaзгo para usar este comando");
}
if(anhelper[playerid] == 1)
{
return SendClientMessage(playerid,COLOR_GRAD1,"Vocк ainda nгo pode fazer um novo anuncio!Espere...");
}
SendClientMessageToAll(COLOR_WHITE,"||-||Aviso dos Helpers||-||");
if(PlayerInfo[playerid][pHelper] >= 3)
{
format(string, sizeof(string), "[HELPER]: {FFFF00}Helper{FF4500} %s:{33FF00} %s", sendername, result);
}
else if(PlayerInfo[playerid][pHelper] >= 10)
{
format(string, sizeof(string), "[HELPER]: {FFFF00}Helper Master{FF4500} %s:{33FF00} %s", sendername, result);
}
else if(PlayerInfo[playerid][pHelper] >= 30)
{
format(string, sizeof(string), "[HELPER]: {FFFF00}Super Helper{FF4500} %s:{33FF00} %s", sendername, result);
}
SendClientMessageToAll(COLOR_HELPER, string);
anhelper[playerid] = 1;
SetTimer("TempoAnHelper",TEMPO_AN,false);
}
return 1;
}
if(strcmp(cmd, "/ahelperchat", true) == 0 || strcmp(cmd, "/ahc", 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[126];
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, "USE: (/ahc) [Chat dos helpers e admins]");
return 1;
}
if (PlayerInfo[playerid][pHelper] >= 1)
{
format(string, sizeof(string), "Helper %s[%d]: %s", sendername, PlayerInfo[playerid][pHelper], result);
SendHelperAdminMessage(COLOR_HELPER, string);
}
else if (PlayerInfo[playerid][pAdmin] >= 1 || IsPlayerAdmin(playerid))
{
format(string, sizeof(string), "Helper %s[%d]: %s", sendername, PlayerInfo[playerid][pHelper], result);
SendHelperAdminMessage(COLOR_HELPER, string);
}
else
{
SendClientMessage(playerid, COLOR_GRAD1, "** vocк nгo estб autorizado a usar esse comando!");
}
}
return 1;
}
if(strcmp(cmd, "/helperchat", true) == 0 || strcmp(cmd, "/hc", 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[126];
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, "USE: (/hc) [Chat dos helpers]");
return 1;
}
format(string, sizeof(string), "Helper %s[%d]: %s", sendername, PlayerInfo[playerid][pHelper], result);
if (PlayerInfo[playerid][pHelper] >= 1)
{
SendHelperMessage(COLOR_HELPER, string);
}
else
{
SendClientMessage(playerid, COLOR_GRAD1, "** vocк nгo estб autorizado a usar esse comando!");
}
}
return 1;
}
if(strcmp(cmd,"/duvida",true) == 0 || strcmp(cmd,"/duv",true) == 0)
{
if(IsPlayerConnected(playerid))
{
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, "Use: /duvida [Pergunta]");
return 1;
}
format(string, sizeof(string), "{33FF00}Dъvida de {FFFF00}%s(ID:%d):{33FF00} %s", sendername, playerid, (result));
SendHelperMessage(COLOR_HELPER, string);
SendClientMessage(playerid, COLOR_GRAD2, "Sua dъvida foi enviada aos Helpers.");
}
return 1;
}
if(strcmp(cmd, "/helpajudar", true) == 0 || strcmp(cmd, "/ha", true) == 0)
{
if(IsPlayerConnected(playerid))
{
if(PlayerInfo[playerid][pHelper] >= 1)
{
if(PlayerInfo[playerid][pHelperTrabalhando] == 0)
{
SendClientMessageToAll(COLOR_WHITE,"||-||Aviso dos Helpers||-||");
format(string, 256, "{33FF00}Helper {FFFF00}%s [%d] {33FF00}estб em trabalho, use /helpers para mais informaзхes.",sendername, playerid);
SendClientMessageToAll(COLOR_HELPER, string);
PlayerInfo[playerid][pHelperTrabalhando] = 1;
}
else if(PlayerInfo[playerid][pHelperTrabalhando] == 1)
{
SendClientMessageToAll(COLOR_WHITE,"||-||Aviso dos Helpers||-||");
format(string, 256, "{33FF00}Helper {FFFF00}%s [%d] {33FF00}estб em jogo, use /helpers para mais informaзхes.",sendername, playerid);
SendClientMessageToAll(COLOR_HELPER, string);
PlayerInfo[playerid][pHelperTrabalhando] = 0;
}
}
else
{
SendClientMessage(playerid, COLOR_GRAD1, "** vocк nгo estб autorizado a usar esse comando!");
}
}
return 1;
}
if(strcmp(cmd, "/meavalie", true) == 0)
{
if(IsPlayerConnected(playerid))
{
tmp = strtok(cmdtext, idx);
if(!strlen(tmp))
{
SendClientMessage(playerid, COLOR_GRAD2, "USE: /meavalie [ID/Nome]");
return 1;
}
new giveplayerid;
giveplayerid = ReturnUser(tmp);
GetPlayerName(giveplayerid, giveplayer, sizeof(giveplayer));
if(IsPlayerConnected(giveplayerid))
{
if(giveplayerid != INVALID_PLAYER_ID)
{
if(PlayerInfo[playerid][pHelper] >= 1)
{
if(PlayerInfo[playerid][pHelperTrabalhando] == 0)
{
return SendClientMessage(playerid,COLOR_GRAD2,"Vocк nгo estб em trabalho!Use: /ha");
}
if(meavaliehelper[playerid] == 1)
{
return SendClientMessage(playerid,COLOR_GRAD1,"Vocк jб foi avaliado recentemente!Espere...");
}
meavalie[giveplayerid] = playerid;
meavaliehelper[playerid] = 1;
SetTimer("TempoAvalieHelper",TEMPO_MEAVALIE,false);
format(string,sizeof(string),"Olб %s\nO Helper %s[ID:%d]\nPediu a vocк que o avalia-se como helper\nCaso ele tenha o ajudado aperte em SIM\nCaso contrario aperte NГO",giveplayer, sendername, playerid);
ShowPlayerDialog(playerid, DIALOG_MEAVALIE, DIALOG_STYLE_MSGBOX, "Avaliaзгo do Helper", string, "Sim", "Nгo");
}
else
{
SendClientMessage(playerid, COLOR_GRAD1, "** vocк nгo estб autorizado a usar esse comando!");
}
}
}
else
{
format(string, sizeof(string), "O jogador nгo estб conectado!", giveplayerid);
SendClientMessage(playerid, COLOR_GRAD1, string);
}
}
return 1;
}
if(strcmp(cmd, "/irh", true) == 0)
{
if(IsPlayerConnected(playerid))
{
tmp = strtok(cmdtext, idx);
if(!strlen(tmp))
{
SendClientMessage(playerid, COLOR_GRAD2, "USE: /irh [ID/Nome]");
return 1;
}
new giveplayerid;
giveplayerid = ReturnUser(tmp);
new Float:givepx,Float:givepy,Float:givepz,Float:givepang;
GetPlayerPos(giveplayerid, givepx, givepy, givepz);
GetPlayerFacingAngle(giveplayerid,givepang);
if(IsPlayerConnected(giveplayerid))
{
if(giveplayerid != INVALID_PLAYER_ID)
{
if(PlayerInfo[playerid][pHelper] >= 10)
{
if(PlayerInfo[playerid][pHelperTrabalhando] == 0)
{
return SendClientMessage(playerid,COLOR_GRAD2,"Vocк nгo estб em trabalho!Use: /ha");
}
SetPlayerInterior(playerid,GetPlayerInterior(giveplayerid));
SetPlayerVirtualWorld(playerid,GetPlayerVirtualWorld(giveplayerid));
SetPlayerPos(playerid,givepx,givepy+2, givepz);
SetPlayerFacingAngle(playerid,givepang);
}
else
{
SendClientMessage(playerid, COLOR_GRAD1, "** vocк nгo estб autorizado a usar esse comando!");
}
}
}
else
{
format(string, sizeof(string), "O jogador nгo estб conectado!", giveplayerid);
SendClientMessage(playerid, COLOR_GRAD1, string);
}
}
return 1;
}
if(strcmp(cmd, "/darhelper", true) == 0)
{
if(IsPlayerConnected(playerid))
{
tmp = strtok(cmdtext, idx);
if(!strlen(tmp))
{
SendClientMessage(playerid, COLOR_GRAD2, "USE: /cmdhpsecreto [playerid/ParteDoNome] [level(0-100)]");
return 1;
}
new playa;
new level;
playa = ReturnUser(tmp);
tmp = strtok(cmdtext, idx);
level = strval(tmp);
if(IsPlayerConnected(playa))
{
if(playa != INVALID_PLAYER_ID)
{
if(level < 0 || level > 25) { SendClientMessage(playerid, COLOR_GREY, "** Nнvel nгo pode ser inferior a 0 ou acima de 100!"); return 1; }
GetPlayerName(playa, giveplayer, sizeof(giveplayer));
PlayerInfo[playa][pHelper] = level;
format(string, sizeof(string), "** Vocк definiu o nivel de helper de %s[ID:%d] para [%d]",giveplayer,playa,level);
SendClientMessage(playerid, COLOR_ORANGE, string);
format(string, sizeof(string), "** Admin %s[ID:%d] definiu seu nivel de helper para [%d]",sendername,playerid,level);
SendClientMessage(playa, COLOR_ORANGE, string);
format(string, sizeof(string), "[HELPER]%s[ID %d] й o novo helper do servidor",giveplayer,playa);
SendHelperMessage(COLOR_HELPER,string);
format(string, sizeof(string), "~b~Parabens %s voce agora e um Helper",giveplayer);
GameTextForPlayer(playa, string, 4500,3);
}
}
}
return 1;
}
return 0;
}
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
new string[128];
new giveplayer[MAX_PLAYER_NAME];
GetPlayerName(meavalie[playerid], giveplayer, sizeof(giveplayer));
new sendername[MAX_PLAYER_NAME];
GetPlayerName(playerid, sendername, sizeof(sendername));
if(dialogid == DIALOG_MEAVALIE)
{
if(response == 1)
{
SendClientMessage(meavalie[playerid],COLOR_GRAD2,"O Jogador qualificou a sua ajuda como {9EC73D}POSITIVA");
PlayerInfo[meavalie[playerid]][pHelper] = PlayerInfo[meavalie[playerid]][pHelper]+1;
format(string, sizeof(string), "Vocк classificou a ajuda do Helper %s como {9EC73D}positiva!",giveplayer);
SendClientMessage(playerid,COLOR_HELPER,string);
}
if(response == 0)
{
SendClientMessage(meavalie[playerid],COLOR_GRAD2,"O Jogador qualificou a sua ajuda como {FF0000}NEGATIVA");
format(string, sizeof(string), "Vocк classificou a ajuda do Helper %s como {FF0000}negativa!",giveplayer);
SendClientMessage(playerid,COLOR_HELPER,string);
}
return 1;
}
if(dialogid == DIALOG_PAR)
{
if(response)
{
format(string, sizeof(string), "Helper %s[ID %d]: %s",sendername,playerid,strlen(inputtext));
SendClientMessage(clickplay[playerid], COLOR_GREY,string);
}
}
if(dialogid == DIALOG_HELPER)
{
if(response)
{
if(listitem == 0)
{
format(string, sizeof(string), "/irh %d",clickplay[playerid]);
OnPlayerCommandText(playerid,string);
}
else if(listitem == 1)
{
format(string, sizeof(string), "/meavalie %d",clickplay[playerid]);
OnPlayerCommandText(playerid,string);
}
else if(listitem == 2)
{
ShowPlayerDialog(playerid, DIALOG_PAR,DIALOG_STYLE_INPUT,"Mensagem","Digite sua mensagem abaixo","Ok","Cancel");
}
}
}
return 1;
}
public OnPlayerClickPlayer(playerid, clickedplayerid, source)
{
if(PlayerInfo[playerid][pHelper] >= 1)
{
clickplay[playerid] = clickedplayerid;
ShowPlayerDialog(playerid,DIALOG_HELPER,DIALOG_STYLE_LIST,"Menu Helper","1\tIr\n2\tSolicitar Avaliaзгo\n3\tMensagem Particular","Selecionar","Cancelar");
}
return 1;
}
strtok(const string[], &index)
{
new length = strlen(string);
while ((index < length) && (string[index] <= ' '))
{
index++;
}
new offset = index;
new result[20];
while ((index < length) && (string[index] > ' ') && ((index - offset) < (sizeof(result) - 1)))
{
result[index - offset] = string[index];
index++;
}
result[index - offset] = EOS;
return result;
}
public SendHelperMessage(color, string[])
{
for(new i = 0; i < MAX_PLAYERS; i++)
{
if(IsPlayerConnected(i))
{
if(PlayerInfo[i][pHelper] >= 1 || IsPlayerAdmin(i))
{
SendClientMessage(i, color, string);
}
}
}
printf("[Helper]%s", string);
}
public SendHelperAdminMessage(color, string[])
{
for(new i = 0; i < MAX_PLAYERS; i++)
{
if(IsPlayerConnected(i))
{
if(PlayerInfo[i][pHelper] >= 1 || IsPlayerAdmin(i) || PlayerInfo[i][pAdmin] >= 1)
{
SendClientMessage(i, color, string);
}
}
}
printf("[Helper]%s", string);
}
public TempoAnHelper(playerid)
{
anhelper[playerid] = 0;
return 1;
}
public TempoAvalieHelper(playerid)
{
meavaliehelper[playerid] = 0;
return 1;
}