if(PlayerInfo[playerid][pKills] > 499) //Ve se ele tem mais de 500 kills
{
//As funcoes aqui
}
else // Ve se ele nгo tem mais de 500 kills
{
//As funcoes aqui
}
return 1;
enum jinfo
{
Mortes,
MembroPolicia,
//pode usar mais se quiser
}
new InfoJogador[playerid][jinfo];
public OnPlayerConnect(playerid)
{
if(InfoJogador[playerid][MembroPolicia] == 1)
{
//funcoes, setar pos dar armas e isso
}
return 1;
}
pawn Код:
|
Erro no InfoJugador! Use o Fini para salvar o jogador!
Download: http://forum.sa-mp.com/showthread.ph...highlight=Fini |
#include <Dini>
new COP;
enum info
{
kills,
prof
}
new Info[MAX_PLAYERS][info];
public OnGameModeInit()
{
COP = AddStaticVehicle(/*MODELO DO CARRO*/, /*COORDENADA X*/, /*COORDENADA Y*/, /*COORDENADA Z*/, /*ANGULO*/, /*COR 1*/, /*COR 2*/)
return 1;
}
public OnPlayerConnect(playerid)
{
Carregar(playerid);
return 1;
}
public OnPlayerDisconnect(playerid, reason)
{
Salvar(playerid);
return 1;
}
public OnPlayerSpawn(playerid)
{
if(Info[prof] == 1)
{
SetPlayerPos(playerid,/*X*/,/*Y*/,/*Z*/);
SetPlayerSkin(playerid,/*ANGULO*/);
SetPlayerArmour(playerid,50);
return 1;
}
return 1;
}
public OnPlayerDeath(playerid,killerid,reason)
{
Info[killerid][kills]++;
return 1;
}
public OnPlayerStateChange(playerid, newstate, oldstate)
{
if(newstate == 2)
{
if(GetPlayerVehicleID(playerid) == COP)
{
if(Info[playerid][prof] != 1)
{
SendClientMessage(playerid, 0xFFF55CFF,"Vocк nгo й policial");
RemovePlayerFromVehicle(playerid);
return 1;
}
}
}
return 1;
}
public OnPlayerCommandText(playerid,cmdtext[])
{
new idx, cmd[256];
cmd = strtok(cmdtext,idx);
if(strcmp(cmd,"/ingressarpolicia",true))
{
if(Info[playerid][kills] < 500) return SendClientMessage(playerid,0xFFF55CFF,"Vocк nao tem 500 kills para ingressar na Policia.");
Info[playerid][prof] = 1;
Salvar(playerid);
return 1;
}
return 0;
}
stock Salvar(playerid)
{
new save[34],nome[MAX_PLAYER_NAME];
GetPlayerName(playerid,nome,sizeof(nome));
format(save,sizeof(save),"Conta%s.ini",nome);
if(!fexist(save))
{
dini_Create(save);
return 1;
}
dini_IntSet(save,"kills",Info[playerid][kills]);
dini_IntSet(save,"prof",Info[playerid][prof]);
return 1;
}
stock Carregar(playerid)
{
new save[34],nome[MAX_PLAYER_NAME];
GetPlayerName(playerid,nome,sizeof(nome));
format(save,sizeof(save),"Conta%s.ini",nome);
Info[playerid][kills] = dini_Int(save,"kills");
Info[playerid][prof] = dini_Int(save,"prof");
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;
}
#define POLICIA 121
stock Policia(playerid)
{
if(PlayerInfo[playerid][pTeam] == POLICIA || GetPlayerTeam(playerid) == POLICIA) return 1;
return 0;
}
stock CarroDaPolicia(carid) // Coloque esta funзгo em qualquer lugar do GM (fora de qualquer funзгo)
{
for(new i = 0; i < sizeof(carrosdapolicia); i++)
{
if(carid == carrosdapolicia[i]) return 1;
}
return 0;
}
//Agora, coloque isso em OnGameModeInit:
//Atenзгo. Isso й apenas um exemplo dos carros que vocк pode colocar. Voc~e pode colocar quantos carros quiser.
new carrosdapolicia[10]; //Quantidade de carros. Sempre adicione um a mais que o ъltimo. Exemplo: O ъltimo й o 9, entгo a array deve ter 10 slots.
carrosdapolicia[0] = AddStaticVehicleEx(599,[PosiзгoX], [PosiзгoY], [PosiзгoZ], [Вngulo],-1,1,3600000); //Police Ranger
carrosdapolicia[1] = AddStaticVehicleEx(596,[PosiзгoX], [PosiзгoY], [PosiзгoZ], [Вngulo],-1,1,3600000); //Police Car (LSPD)
carrosdapolicia[2] = AddStaticVehicleEx(472,[PosiзгoX], [PosiзгoY], [PosiзгoZ], [Вngulo],-1,1,3600000); // BARCO LSPD
carrosdapolicia[3] = AddStaticVehicleEx(430,[PosiзгoX], [PosiзгoY], [PosiзгoZ], [Вngulo],-1,1,3600000); // PREDATOR LSPD
carrosdapolicia[4] = AddStaticVehicleEx(523,[PosiзгoX], [PosiзгoY], [PosiзгoZ], [Вngulo],-1,1,3600000); //HPV1000
carrosdapolicia[5] = AddStaticVehicleEx(597,[PosiзгoX], [PosiзгoY], [PosiзгoZ], [Вngulo],-1,1,3600000); //Police Car (SFPD)
carrosdapolicia[6] = AddStaticVehicleEx(427,[PosiзгoX], [PosiзгoY], [PosiзгoZ], [Вngulo],-1,1,3600000); //Enforcer
carrosdapolicia[7] = AddStaticVehicleEx(426,[PosiзгoX], [PosiзгoY], [PosiзгoZ], [Вngulo],-1,1,3600000); //Premier
carrosdapolicia[8] = AddStaticVehicleEx(601,[PosiзгoX], [PosiзгoY], [PosiзгoZ], [Вngulo],-1,1,3600000);//S.W.A.T. Van
carrosdapolicia[9] = AddStaticVehicleEx(427,[PosiзгoX], [PosiзгoY], [PosiзгoZ], [Вngulo],-1,1,3600000); //Enforcer
new vehicle = GetPlayerVehicleID(playerid);
if(newstate == PLAYER_STATE_DRIVER)
{
new vehicleid = GetPlayerVehicleID(playerid);
if(CarrosDaPolicia(vehicleid))
{
if(Policial(playerid))
{
SendClientMessage(playerid, 0x0080FFFF, ":: Este veнculo pertence a Polнcia ::");
}
else
{
SendClientMessage(playerid, 0xAFAFAFFF, "Vocк nгo pode dirigir este carro.!");
RemovePlayerFromVehicle(playerid);
}
}
}
if(GetPlayerTeam(playerid) == POLICIA || PlayerInfo[playerid][pTeam] == POLICIA) SetSpawnInfo(playerid, POLICIA, [skin], [Posiзгo do Spawn X], [Posiзгo do Spawn Y] ,[Posiзгo do Spawn Z], [Вngulo], [Arma de Spawn 1], [Muniзгo de Spawn 1], [Arma de Spawn 2], [Muniзгo de Spawn 2], [Arma de Spawn 3], [Muniзгo de Spawn 3]);
PlayerInfo[killerid][pKills]++;
if(!strcmp(cmd, "/ingressarpolicia", true))
{
new Float:pos[500][3];
GetPlayerPos(playerid, pos[playerid][0], pos[playerid][1], pos[playerid][2]);
if(pos[playerid][0] == [posiзгo x de onde vocк quer que digite o comando] && pos[playerid][1] == [posiзгo y de onde vocк quer que digite o comando] && pos[playerid][2] == [posiзгo z de onde vocк quer que digite o comando])
{
if(PlayerInfo[playerid][pKills] < 500) return SendClientMessage(playerid, 0xAFAFAFFF, "Vocк nгo matou gente suficiente pra entrar na polнcia!");
SetPlayerTeam(playerid, POLICIA);
SpawnPlayer(playerid);
return SendClientMessage(playerid, 0xAFAFAFFF, "Vocк agora й um policial!");
}
else return SendClientMessage(playerid, 0xAFAFAFFF, "Vocк nгo estб no lugar que ingressa na polнcia!");
return 1;
}
carrosdapolicia[0] = AddStaticVehicleEx(599,[PosiзгoX], [PosiзгoY], [PosiзгoZ], [Вngulo],-1,1,3600000); //Police Ranger
carrosdapolicia[1] = AddStaticVehicleEx(596,[PosiзгoX], [PosiзгoY], [PosiзгoZ], [Вngulo],-1,1,3600000); //Police Car (LSPD)
carrosdapolicia[2] = AddStaticVehicleEx(472,[PosiзгoX], [PosiзгoY], [PosiзгoZ], [Вngulo],-1,1,3600000); // BARCO LSPD
carrosdapolicia[3] = AddStaticVehicleEx(430,[PosiзгoX], [PosiзгoY], [PosiзгoZ], [Вngulo],-1,1,3600000); // PREDATOR LSPD
carrosdapolicia[4] = AddStaticVehicleEx(523,[PosiзгoX], [PosiзгoY], [PosiзгoZ], [Вngulo],-1,1,3600000); //HPV1000
carrosdapolicia[5] = AddStaticVehicleEx(597,[PosiзгoX], [PosiзгoY], [PosiзгoZ], [Вngulo],-1,1,3600000); //Police Car (SFPD)
carrosdapolicia[6] = AddStaticVehicleEx(427,[PosiзгoX], [PosiзгoY], [PosiзгoZ], [Вngulo],-1,1,3600000); //Enforcer
carrosdapolicia[7] = AddStaticVehicleEx(426,[PosiзгoX], [PosiзгoY], [PosiзгoZ], [Вngulo],-1,1,3600000); //Premier
carrosdapolicia[8] = AddStaticVehicleEx(601,[PosiзгoX], [PosiзгoY], [PosiзгoZ], [Вngulo],-1,1,3600000);//S.W.A.T. Van
carrosdapolicia[9] = AddStaticVehicleEx(427,[PosiзгoX], [PosiзгoY], [PosiзгoZ], [Вngulo],-1,1,3600000); //Enforcer
//ISSO DEVE FICAR NO ONGAMEMODEINIT
----------------------------------------------------------
//Nгo entendi uma coisa:
new Float:pos[500][3];
Para que esse [500] ?