#include <a_samp>
#include <dof2>
new string[50];
public OnFilterScriptExit() {
DOF2_Exit();
return 1;
}
public OnPlayerDisconnect(playerid, reason) {
static name[24], str[50], weapon, ammo;
GetPlayerName(playerid, name, sizeof(name));
format(string, 50, "Armas/%s.ini", name);
DOF2_CreateFile(string);
for(new i = 1; i < 13; ++i) {
GetPlayerWeaponData(playerid, i, weapon, ammo);
format(str, sizeof(str), "Arma%d", i);
DOF2_SetInt(string, str, weapon);
format(str, sizeof(str), "Municao%d", i);
DOF2_SetInt(string, str, ammo);
}
DOF2_SaveFile();
return 1;
}
public OnPlayerSpawn(playerid) {
static name[24], str[50];
GetPlayerName(playerid, name, sizeof(name));
format(string, 50, "Armas/%s.ini", name);
if(DOF2_FileExists(string)) {
static weapon, ammo;
for(new i = 1; i < 13; ++i) {
format(str, sizeof(str), "Arma%d", i);
weapon = DOF2_GetInt(string, str);
format(str, sizeof(str), "Municao%d", i);
ammo = DOF2_GetInt(string, str);
GivePlayerWeapon(playerid, weapon, ammo);
}
}
return 1;
}
#include <a_samp> #include <DOF2> public OnPlayerSpawn(playerid) { LoadWeapons(playerid); return 1; } public OnGameModeExit() { DOF2_Exit(); return 1; } public OnPlayerDisconnect(playerid) { SaveWeapons(playerid); return 1; } SaveWeapons(playerid) { new weapons[13][2], wstring[56], armap[24]; format(wstring, sizeof(wstring), "Armas/%s.ini", GetNick(playerid)); if(!DOF2_FileExists(wstring)) DOF2_CreateFile(wstring); if(DOF2_FileExists(wstring)) { for (new i = 0; i < 13; i++) { GetPlayerWeaponData(playerid, i, weapons[i][0], weapons[i][1]); format(armap, sizeof(armap), "Weapon%d", i); DOF2_SetInt(wstring, armap, weapons[i][0]); format(armap, sizeof(armap), "Ammo%d", i); DOF2_SetInt(wstring, armap, weapons[i][1]); } DOF2_SaveFile(); print("Armas Salvas"); } return 1; } LoadWeapons(playerid) { new wstring[56], armap[24], weapons[13][2]; format(wstring, sizeof(wstring), "Armas/%s.ini", GetNick(playerid)); if(!DOF2_FileExists(wstring)) return 1; if(DOF2_FileExists(wstring)) { for (new i = 0; i < 13; i++) { format(armap, sizeof(armap), "Weapon%d", i); weapons[i][0] = DOF2_GetInt(wstring, armap); format(armap, sizeof(armap), "Ammo%d", i); weapons[i][1] = DOF2_GetInt(wstring, armap); if(weapons[i][0] != 0) GivePlayerWeapon(playerid, weapons[i][0], weapons[i][1]); } print("Armas Carregadas"); } return 1; } GetNick(playerid) { new name[MAX_PLAYER_NAME]; GetPlayerName(playerid, name, MAX_PLAYER_NAME); return name; }
Pedro foi mais rбpido... que pena...
Obs: Crie a pasta Armas. Код:
#include <a_samp> #include <DOF2> public OnPlayerSpawn(playerid) { LoadWeapons(playerid); return 1; } public OnGameModeExit() { DOF2_Exit(); return 1; } public OnPlayerDisconnect(playerid) { SaveWeapons(playerid); return 1; } SaveWeapons(playerid) { new weapons[13][2], wstring[56], armap[24]; format(wstring, sizeof(wstring), "Armas/%s.ini", GetNick(playerid)); if(!DOF2_FileExists(wstring)) DOF2_CreateFile(wstring); if(DOF2_FileExists(wstring)) { for (new i = 0; i < 13; i++) { GetPlayerWeaponData(playerid, i, weapons[i][0], weapons[i][1]); format(armap, sizeof(armap), "Weapon%d", i); DOF2_SetInt(wstring, armap, weapons[i][0]); format(armap, sizeof(armap), "Ammo%d", i); DOF2_SetInt(wstring, armap, weapons[i][1]); } DOF2_SaveFile(); print("Armas Salvas"); } return 1; } LoadWeapons(playerid) { new wstring[56], armap[24], weapons[13][2]; format(wstring, sizeof(wstring), "Armas/%s.ini", GetNick(playerid)); if(!DOF2_FileExists(wstring)) return 1; if(DOF2_FileExists(wstring)) { for (new i = 0; i < 13; i++) { format(armap, sizeof(armap), "Weapon%d", i); weapons[i][0] = DOF2_GetInt(wstring, armap); format(armap, sizeof(armap), "Ammo%d", i); weapons[i][1] = DOF2_GetInt(wstring, armap); if(weapons[i][0] != 0) GivePlayerWeapon(playerid, weapons[i][0], weapons[i][1]); } print("Armas Carregadas"); } return 1; } GetNick(playerid) { new name[MAX_PLAYER_NAME]; GetPlayerName(playerid, name, MAX_PLAYER_NAME); return name; } Bom uso... |
Originally Posted by Tony_Rodrigues
Tem certeza que foi vc que fez?
|
Sim tenho certeza... nao preciso copiar, nada, e de ninguйm.
@TOPIC SaveWeapons(playerid); Coloque aonde achar que viavel colocar... onde sabe que nao hб muita frequencia de pessoas ativando a funзгo de salvamento. |
pawn Код:
|
local variable "string" shadows a variable at a preceding level
local variable "string" shadows a variable at a preceding level
local variable "string" shadows a variable at a preceding level