12.01.2011, 00:09
Estuda o sisteminha que fiz й facinho aprender:
Cria uma pasta nome (Players) nas scriptfiles
Cria uma pasta nome (Players) nas scriptfiles
pawn Код:
#include <a_samp>
#include "Dini"
#define PastaKits "Players/%s.ini"
#define Kits 1458
new Kit[MAX_PLAYERS];
main()
{
print("\n----------------------------------");
print(" Kit de Armas By: [NWD]Jim._.Carrey ");
print("----------------------------------\n");
}
public OnPlayerDisconnect(playerid, reason)
{
SalvarKit(playerid);
return 1;
}
public OnPlayerSpawn(playerid)
{
CarregarKit(playerid);
return 1;
}
public OnPlayerCommandText(playerid, cmdtext[])
{
if(strcmp("/Kit2", cmdtext, true, 10) == 0)
{
ShowPlayerDialog(playerid, Kits, DIALOG_STYLE_LIST, "Kit's de Armas","1 - Sawn-off Tec9 e Eagle - $20.000\n2 - Micro SMG MP5 e Sniper - $22.000\nShotgun 9mm e AK-47","Comprar", "Cancelar");
return 1;
}
return 0;
}
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
if(dialogid == Kits)
{
if(response)
{
switch (listitem)
{
case 0:
{
SendClientMessage(playerid, 0xFF00AA, "(KIT) Parabйns Kit n°1 adquirido com sucesso! ( Ealge, Sawn-Off, Tec9 )");
new player[128];
format(player, sizeof(player), Contas, Nome(playerid));
Kit[playerid] = dini_IntSet(player, "Kit", 1);
ResetPlayerWeapons(playerid);
GivePlayerWeapon(playerid, 24, 9999);// Eagle
GivePlayerWeapon(playerid, 26, 9999);// Sawn-Off
GivePlayerWeapon(playerid, 32, 9999);// Tec9
return 1;
}
case 1:
{
SendClientMessage(playerid, 0xFF00AA, "(KIT) Parabйns Kit n°1 adquirido com sucesso! ( Micro, MP5, Sniper )");
new player[128];
format(player, sizeof(player), Contas, Nome(playerid));
ResetPlayerWeapons(playerid);
GivePlayerWeapon(playerid, 28, 9999);// Micro SMG
GivePlayerWeapon(playerid, 29, 9999);// MP5
GivePlayerWeapon(playerid, 34, 9999);// Sniper
Kit[playerid] = dini_IntSet(player, "Kit", 2);
return 1;
}
case 2:
{
SendClientMessage(playerid, 0xFF00AA, "(KIT) Parabйns Kit n°1 adquirido com sucesso! ( Shotgun, 9mm, AK-47 )");
new player[128];
format(player, sizeof(player), Contas, Nome(playerid));
ResetPlayerWeapons(playerid);
GivePlayerWeapon(playerid, 25, 9999);// Shotgun
GivePlayerWeapon(playerid, 22, 9999);// 9mm
GivePlayerWeapon(playerid, 30, 9999);// AK-47
Kit[playerid] = dini_IntSet(player, "Kit", 3);
return 1;
}
}
}
}
return 1;
}
stock CarregarKit(playerid)
{
new player[128];
format(player, sizeof(player), Contas, Nome(playerid));
Kit[playerid] = dini_Int(player, "Kit");
if(Kit[playerid] == 1)
{
ResetPlayerWeapons(playerid);
GivePlayerWeapon(playerid, 24, 9999);// Eagle
GivePlayerWeapon(playerid, 26, 9999);// Sawn-Off
GivePlayerWeapon(playerid, 32, 9999);// Tec9
return 1;
}
else if(Kit[playerid] == 2)
{
ResetPlayerWeapons(playerid);
GivePlayerWeapon(playerid, 28, 9999);// Micro SMG
GivePlayerWeapon(playerid, 29, 9999);// MP5
GivePlayerWeapon(playerid, 34, 9999);// Sniper
return 1;
}
else if(Kit[playerid] == 3)
{
ResetPlayerWeapons(playerid);
GivePlayerWeapon(playerid, 25, 9999);// Shotgun
GivePlayerWeapon(playerid, 22, 9999);// 9mm
GivePlayerWeapon(playerid, 30, 9999);// AK-47
return 1;
}
return 1;
}
stock SalvarKit(playerid)
{
new player[128];
format(player, sizeof(player), Contas, Nome(playerid));
if(Kit[playerid] == 1)
{
dini_IntSet(player, "Kit", 1);
}
else if(Kit[playerid] == 2)
{
dini_IntSet(player, "Kit", 2);
}
return 1;
}
stock Nome(playerid)
{
new nome[MAX_PLAYER_NAME];
GetPlayerName(playerid, nome, sizeof(nome));
return nome;
}