Szerző Téma: Széf probléma!  (Megtekintve 1348 alkalommal)

Széf probléma!
« Dátum: 2014. augusztus 08. - 18:40:06 »
0 Show voters
Sziasztok!
A Gagis House Systembõl megpróbáltam kiszedni a széf rendszert csak akadt vele elég sok problémám :D
Sajnos mivel nem vagyok nagy scripter így elég hamar megakadtam benne.
Sajnos a mentése sem éppen a legjobb ezért azt szeretném hogyha a játékos beüti hogy /lerakszef akkor tegye le a széfet arra a pozícióra ahol éppen áll. Ez részben sikerült is és még objectet is tudtam neki adni ámde az a baj hogy ezeket nem menti el a script. És azt szeretném még hogy ahová lerakom a széfet ott lehessen használni a széfhez tartozó parancsokat. Ezekkel is próbálkoztam, de sajnos ezek sem sikerültek :(
valaki tudna nekem segíteni megoldani ezeket a problémákat ?
Elõre is nagyon köszönöm!
A házrendszer amibõl megpróbáltam kiszedni a széfrendszert:
http://forum.sa-mp.com/showthread.php?t=321388
Az általam összeállított script:
 
#include <a_samp>
#include <foreach>
#include <sscanf2>
#include <YSI\\y_ini>
#include <YSI\\y_commands>
#include <streamer>
#define House_File  \"Széfek/%d.ini\"
#define SCM SendClientMessage
#define COLOR_RED 0xE01B4CFF
#define COL_GREEN \"{2EAD15}\"
#define COL_WHITE \"{FFFFFF}\"
#define COL_YELLOW \"{F5E618}\"
#define MAX_HOUSE   500
#define MAX_SZEF 20
public OnGameModeInit()
{
for(new i = 0; i <= MAX_HOUSE; i++)
     {
         new gFile[35];
format(gFile, 35, House_File ,i);
if(fexist(gFile))
{
INI_ParseFile(gFile, \"LoadHouse\", .bExtra = true, .extra = i);
}
}
return 1;
}
enum plinfo
{
Houseid,
}
new Player[MAX_PLAYERS][plinfo];
enum house
{
Float:ExitX,
Float:ExitY,
Float:ExitZ,
Money,
Gun1,
Gun2,
Ammo1,
Ammo2,
}
new House[MAX_HOUSE][house];
stock CreateSaveHouse(id,Float:PosX,Float:PosY,Float:PosZ)
{
   new dFile[32];
   new Year, Month, Day;
   getdate(Year, Month, Day);
   format(dFile, 35, House_File, id);
   new
   INI:File = INI_Open(dFile);
          INI_WriteFloat(File, \"EnterX\", PosX);
          INI_WriteFloat(File, \"EnterY\", PosY);
          INI_WriteFloat(File, \"EnterZ\", PosZ);
          INI_WriteFloat(File, \"ExitX\", 223.42928466797);
          INI_WriteFloat(File, \"ExitY\", 1287.3064941406);
          INI_WriteFloat(File, \"ExitZ\", 1082.14);
          INI_WriteInt(File, \"Money\", 0);
          INI_WriteInt(File, \"Gun1\", 0);
          INI_WriteInt(File, \"Gun2\", 0);
          INI_WriteInt(File, \"Ammo1\", 0);
          INI_WriteInt(File, \"Ammo2\", 0);
          INI_Close(File);
            House[id][ExitX] = 223.42928466797;
            House[id][ExitY] = 1287.3064941406;
            House[id][ExitZ] = 1082.14;
            House[id][Money] = 0;
            House[id][Gun1] = 0;
            House[id][Gun2] = 0;
            House[id][Ammo1] = 0;
            House[id][Ammo2] = 0;
}
forward LoadHouse(id, name[], value[]);
public LoadHouse(id, name[], value[])
{
    INI_Float(\"ExitX\", House[id][ExitX]);
    INI_Float(\"ExitY\", House[id][ExitY]);
    INI_Float(\"ExitZ\", House[id][ExitZ]);
INI_Int(\"Money\", House[id][Money]);
INI_Int(\"Gun1\", House[id][Gun1]);
INI_Int(\"Gun2\", House[id][Gun2]);
INI_Int(\"Ammo1\", House[id][Ammo1]);
INI_Int(\"Ammo2\", House[id][Ammo2]);
return 1;
}
YCMD:lerakszef(playerid, params[], help)
{
           #pragma unused help
           #pragma unused params
           new money;
        new id = Player[playerid][Houseid];
            new Float:Pos[3], a;
        if(sscanf(params, \"i\",money)) return SCM(playerid, COLOR_RED, \"Usage: /lerakszef [FRAKCIÓ ID]\");
   if (money < 1 || money > MAX_SZEF + 1) return SendClientMessage(playerid, COLOR_RED, \"Ismeretlen frakció ID!\");
    if (id == -1) return SendClientMessage(playerid, COLOR_RED, \"Nem tudsz több széfet lerakni! Elérted a maximum limietet!(20db széf van letéve összesen!)\");
   GetPlayerPos(playerid,Pos[0],Pos[1],Pos[2]);
   CreateSaveHouse(id,Pos[0],Pos[1],Pos[2]);
   CreateDynamicObject(1829, Pos[0],Pos[1],Pos[2]-0.4, 0.0, 0.0, a, -1, -1, -1, 200.0);
   CheckHouse(id);
   SCM(playerid, COLOR_RED, \"Széf lerakva!\");
        return 1;
}
YCMD:berakpenz(playerid, params[], help)
{
        #pragma unused help
        #pragma unused params
        new id = Player[playerid][Houseid];
        if(id == 999) return SCM(playerid,COLOR_RED,\"EROR: \"COL_WHITE\"You don\'t have a house.\");
        new string[128],money;
if(!IsPlayerInRangeOfPoint(playerid,5.0,House[id][ExitX],House[id][ExitY],House[id][ExitZ])) return SCM(playerid,COLOR_RED,\"You are not at right position!\");
if(sscanf(params, \"i\",money)) return SCM(playerid, COLOR_RED, \"Usage: /hdeposit [Money]\");
if(money > GetPlayerMoney(playerid)) return SCM(playerid, COLOR_RED, \"You don\'t have that kind of money.\");
if(money < 1) return SCM(playerid, COLOR_RED, \"A berani kívánt összegnek minimum 1FT-nak kell lennie!\");
        House[id][Money] += money;
        GivePlayerMoney(playerid, -money);
format(string,sizeof(string),\"{E0BC1B}You have put in the safe $%d.Now you have $%d\",money,House[id][Money]);
        SCM(playerid,-1,string);
        CheckHouse(id);
return 1;
}
YCMD:kiveszpenz(playerid, params[], help)
{
        #pragma unused help
        #pragma unused params
        new id = Player[playerid][Houseid];
        if(id == 999) return SCM(playerid,COLOR_RED,\"EROR: \"COL_WHITE\"You don\'t have a house.\");
        new string[128],money;
if(!IsPlayerInRangeOfPoint(playerid,5.0,House[id][ExitX],House[id][ExitY],House[id][ExitZ])) return SCM(playerid,COLOR_RED,\"You are not in your house!\");
if(sscanf(params, \"i\",money)) return SCM(playerid, COLOR_RED, \"Usage: /hwithdraw [Money]\");
if(money > House[id][Money]) return SCM(playerid, COLOR_RED, \"You Don\'t have this sum of money.\");
if(money < 1) return SCM(playerid, COLOR_RED, \"Money can\'t be less then 1\");
        House[id][Money] -= money;
        GivePlayerMoney(playerid, money);
format(string,sizeof(string),\"\"COL_YELLOW\"You are take from safe\"COL_GREEN\"$%d\"COL_YELLOW\".Now there is \"COL_GREEN\"$%d\",money,House[id][Money]);
        SCM(playerid,-1,string);
        CheckHouse(id);
return 1;
}
YCMD:berakfegyver(playerid, params[], help)
{
        #pragma unused help
        #pragma unused params
          new id = Player[playerid][Houseid];
        if(id == 999) return SCM(playerid,COLOR_RED,\"EROR: \"COL_WHITE\"You don\'t have a house.\");
        new string[128],slot,ammo;
if(!IsPlayerInRangeOfPoint(playerid,30.0,House[id][ExitX],House[id][ExitY],House[id][ExitZ])) return SCM(playerid,COLOR_RED,\"You are not at right position!\");
if(sscanf(params, \"ii\",slot,ammo)) return SCM(playerid, COLOR_RED, \"Usage: /hputgun [slot 1/2] [Ammo]\");
if(ammo > GetPlayerAmmo(playerid)) return SCM(playerid, COLOR_RED, \"You don\'t have that much ammo.\");
if(ammo < 1) return SCM(playerid, COLOR_RED, \"Ammo can\'t be less then 1\");
if(slot == 1)
{
if(House[id][Gun1] != 0) return SCM(playerid,COLOR_RED,\"EROR: \"COL_WHITE\"There is already gun on this slot.\");
        House[id][Gun1] = GetPlayerWeapon(playerid);
        House[id][Ammo1] = ammo;
        SetPlayerAmmo(playerid,GetPlayerWeapon(playerid),GetPlayerAmmo(playerid)-ammo);
format(string,sizeof(string),\"{E0BC1B}You have put gun on slot 1.With %d ammo\",ammo);
        SCM(playerid,-1,string);
        CheckHouse(id);
        }
if(slot == 2)
{
if(House[id][Gun2] != 0) return SCM(playerid,COLOR_RED,\"EROR: \"COL_WHITE\"There is already gun on this slot.\");
        House[id][Gun2] = GetPlayerWeapon(playerid);
        House[id][Ammo2] = ammo;
        SetPlayerAmmo(playerid,GetPlayerWeapon(playerid),GetPlayerAmmo(playerid)-ammo);
format(string,sizeof(string),\"{E0BC1B}You have put gun on slot 2.With %d ammo\",ammo);
        SCM(playerid,-1,string);
        CheckHouse(id);
        }
return 1;
}
YCMD:kiveszfegyver(playerid, params[], help)
{
        #pragma unused help
        #pragma unused params
          new id = Player[playerid][Houseid];
        if(id == 999) return SCM(playerid,COLOR_RED,\"HIBA: \"COL_WHITE\"Nem vagy széf közelében!\");
if(!IsPlayerInRangeOfPoint(playerid,5.0,House[id][ExitX],House[id][ExitY],House[id][ExitZ])) return SCM(playerid,COLOR_RED,\"Nem vagy széf közelében!\");
        new string[128],slot,ammo;
if(!IsPlayerInRangeOfPoint(playerid,5.0,House[id][ExitX],House[id][ExitY],House[id][ExitZ])) return SCM(playerid,COLOR_RED,\"Nem vagy széf közelében!\");
if(sscanf(params, \"ii\",slot,ammo)) return SCM(playerid, COLOR_RED, \"Használat: /kiveszfegyver [Fegyver hely 1/2] [Lõszer]\");
if(ammo < 1) return SCM(playerid, COLOR_RED, \"A lõszer minimum 10db maximum 50db lehet!\");
if(slot == 1)
{
if(House[id][Gun1] == 0) return SCM(playerid,COLOR_RED,\"HIBA: \"COL_WHITE\"There is no gun on this slot.\");
if(ammo > House[id][Ammo1]) return SCM(playerid, COLOR_RED, \"EROR:\"COL_WHITE\" In the safe does not have that much ammo.\");
GivePlayerWeapon(playerid,House[id][Gun1],ammo);
House[id][Ammo1] -= ammo;
if(House[id][Ammo1] == 0) {House[id][Gun1] = 0;}
format(string,sizeof(string),\"{E0BC1B}You are take gun from slot 1.With %d ammo\",ammo);
        SCM(playerid,-1,string);
        CheckHouse(id);
        }
if(slot == 2)
{
if(House[id][Gun2] == 0) return SCM(playerid,COLOR_RED,\"EROR: \"COL_WHITE\"There is no gun on this slot.\");
if(ammo > House[id][Ammo2]) return SCM(playerid, COLOR_RED, \"EROR:\"COL_WHITE\" In the safe does not have that much ammo.\");
GivePlayerWeapon(playerid,House[id][Gun2],ammo);
House[id][Ammo2] -= ammo;
if(House[id][Ammo2] == 0) {House[id][Gun2] = 0;}
format(string,sizeof(string),\"{E0BC2B}You have taken gun from slot 2.With %d ammo\",ammo);
        SCM(playerid,-1,string);
        CheckHouse(id);
        }
return 1;
}
YCMD:megnezszef(playerid, params[], help)
{
        #pragma unused help
        #pragma unused params
          new h = Player[playerid][Houseid];
        if(h == 999) return SCM(playerid,COLOR_RED,\"HIBA: \"COL_WHITE\"Nem vagy széf közelében!\");
        new string[128];
format(string,sizeof(string),\"\"COL_YELLOW\"A széfben\"COL_GREEN\" %dFT van!\",House[h][Money]);
format(string,sizeof(string),\"\"COL_YELLOW\"Fegyver hely 1 | Fegyver:\"COL_GREEN\" %d \"COL_YELLOW\"| Lõszer:\"COL_GREEN\" %d db\",House[h][Gun1],House[h][Ammo1]);
format(string,sizeof(string),\"\"COL_YELLOW\"Fegyver hely 2 | Fegyver:\"COL_GREEN\" %d \"COL_YELLOW\"| Lõszer:\"COL_GREEN\" %d db\",House[h][Gun2],House[h][Ammo2]);
        SCM(playerid,-1,string);
return 1;
}
stock CheckHouse(id)
{
new dFile[32];
format(dFile, 35, House_File, id);
new
   INI:File = INI_Open(dFile);
INI_WriteFloat(File, \"ExitX\", House[id][ExitX]);
INI_WriteFloat(File, \"ExitY\", House[id][ExitY]);
INI_WriteFloat(File, \"ExitZ\", House[id][ExitZ]);
INI_WriteInt(File, \"Money\", House[id][Money]);
INI_WriteInt(File, \"Gun1\", House[id][Gun1]);
INI_WriteInt(File, \"Gun2\", House[id][Gun2]);
INI_WriteInt(File, \"Ammo1\", House[id][Ammo1]);
INI_WriteInt(File, \"Ammo2\", House[id][Ammo2]);
INI_Close(File);
« Utoljára szerkesztve: 2014. október 19. - 16:34:02 írta Flash »

Széf probléma!
« Válasz #1 Dátum: 2014. augusztus 12. - 10:03:23 »
0 Show voters
Üdv!
Én amennyit látok belõle az az, hogy kiszeded az alábbiakat:
Enumból:
 

Money,
Gun1,
Gun2,
Ammo1,
Ammo2,

 
CreateSaveHouse-ból:
 

INI_WriteInt(File, \"Money\", 0);
INI_WriteInt(File, \"Gun1\", 0);
INI_WriteInt(File, \"Gun2\", 0);
INI_WriteInt(File, \"Ammo1\", 0);
INI_WriteInt(File, \"Ammo2\", 0);
House[id][Money] = 0;
House[id][Gun1] = 0;           
House[id][Gun2] = 0;
House[id][Ammo1] = 0;
House[id][Ammo2] = 0;

 
LoadHouse-ból:
 

INI_Int(\"Money\", House[id][Money]);
INI_Int(\"Gun1\", House[id][Gun1]);
INI_Int(\"Gun2\", House[id][Gun2]);
INI_Int(\"Ammo1\", House[id][Ammo1]);
INI_Int(\"Ammo2\", House[id][Ammo2]);

 
Parancsok:
 
YCMD:berakpenz(playerid, params[], help)
{
        #pragma unused help
        #pragma unused params
        new id = Player[playerid][Houseid];
        if(id == 999) return SCM(playerid,COLOR_RED,\"EROR: \"COL_WHITE\"You don\'t have a house.\");
        new string[128],money;
                if(!IsPlayerInRangeOfPoint(playerid,5.0,House[id][ExitX],House[id][ExitY],House[id][ExitZ])) return SCM(playerid,COLOR_RED,\"You are not at right position!\");
                if(sscanf(params, \"i\",money)) return SCM(playerid, COLOR_RED, \"Usage: /hdeposit [Money]\");
                if(money > GetPlayerMoney(playerid)) return SCM(playerid, COLOR_RED, \"You don\'t have that kind of money.\");
                if(money < 1) return SCM(playerid, COLOR_RED, \"A berani kívánt összegnek minimum 1FT-nak kell lennie!\");
        House[id][Money] += money;
        GivePlayerMoney(playerid, -money);
                format(string,sizeof(string),\"{E0BC1B}You have put in the safe $%d.Now you have $%d\",money,House[id][Money]);
        SCM(playerid,-1,string);
        CheckHouse(id);
                return 1;
}
YCMD:kiveszpenz(playerid, params[], help)
{
        #pragma unused help
        #pragma unused params
        new id = Player[playerid][Houseid];
        if(id == 999) return SCM(playerid,COLOR_RED,\"EROR: \"COL_WHITE\"You don\'t have a house.\");
        new string[128],money;
                if(!IsPlayerInRangeOfPoint(playerid,5.0,House[id][ExitX],House[id][ExitY],House[id][ExitZ])) return SCM(playerid,COLOR_RED,\"You are not in your house!\");
                if(sscanf(params, \"i\",money)) return SCM(playerid, COLOR_RED, \"Usage: /hwithdraw [Money]\");
                if(money > House[id][Money]) return SCM(playerid, COLOR_RED, \"You Don\'t have this sum of money.\");
                if(money < 1) return SCM(playerid, COLOR_RED, \"Money can\'t be less then 1\");
        House[id][Money] -= money;
        GivePlayerMoney(playerid, money);
                format(string,sizeof(string),\"\"COL_YELLOW\"You are take from safe\"COL_GREEN\"$%d\"COL_YELLOW\".Now there is \"COL_GREEN\"$%d\",money,House[id][Money]);
        SCM(playerid,-1,string);
        CheckHouse(id);
                return 1;
}
YCMD:berakfegyver(playerid, params[], help)
{
        #pragma unused help
        #pragma unused params
        new id = Player[playerid][Houseid];
        if(id == 999) return SCM(playerid,COLOR_RED,\"EROR: \"COL_WHITE\"You don\'t have a house.\");
        new string[128],slot,ammo;
                if(!IsPlayerInRangeOfPoint(playerid,30.0,House[id][ExitX],House[id][ExitY],House[id][ExitZ])) return SCM(playerid,COLOR_RED,\"You are not at right position!\");
                if(sscanf(params, \"ii\",slot,ammo)) return SCM(playerid, COLOR_RED, \"Usage: /hputgun [slot 1/2] [Ammo]\");
                if(ammo > GetPlayerAmmo(playerid)) return SCM(playerid, COLOR_RED, \"You don\'t have that much ammo.\");
                if(ammo < 1) return SCM(playerid, COLOR_RED, \"Ammo can\'t be less then 1\");
                if(slot == 1)
                {
                if(House[id][Gun1] != 0) return SCM(playerid,COLOR_RED,\"EROR: \"COL_WHITE\"There is already gun on this slot.\");
        House[id][Gun1] = GetPlayerWeapon(playerid);
        House[id][Ammo1] = ammo;
        SetPlayerAmmo(playerid,GetPlayerWeapon(playerid),GetPlayerAmmo(playerid)-ammo);
                format(string,sizeof(string),\"{E0BC1B}You have put gun on slot 1.With %d ammo\",ammo);
        SCM(playerid,-1,string);
        CheckHouse(id);
        }
                if(slot == 2)
                {
                if(House[id][Gun2] != 0) return SCM(playerid,COLOR_RED,\"EROR: \"COL_WHITE\"There is already gun on this slot.\");
        House[id][Gun2] = GetPlayerWeapon(playerid);
        House[id][Ammo2] = ammo;
        SetPlayerAmmo(playerid,GetPlayerWeapon(playerid),GetPlayerAmmo(playerid)-ammo);
                format(string,sizeof(string),\"{E0BC1B}You have put gun on slot 2.With %d ammo\",ammo);
        SCM(playerid,-1,string);
        CheckHouse(id);
        }
                return 1;
}
YCMD:kiveszfegyver(playerid, params[], help)
{
        #pragma unused help
        #pragma unused params
        new id = Player[playerid][Houseid];
        if(id == 999) return SCM(playerid,COLOR_RED,\"HIBA: \"COL_WHITE\"Nem vagy széf közelében!\");
                if(!IsPlayerInRangeOfPoint(playerid,5.0,House[id][ExitX],House[id][ExitY],House[id][ExitZ])) return SCM(playerid,COLOR_RED,\"Nem vagy széf közelében!\");
        new string[128],slot,ammo;
                if(!IsPlayerInRangeOfPoint(playerid,5.0,House[id][ExitX],House[id][ExitY],House[id][ExitZ])) return SCM(playerid,COLOR_RED,\"Nem vagy széf közelében!\");
                if(sscanf(params, \"ii\",slot,ammo)) return SCM(playerid, COLOR_RED, \"Használat: /kiveszfegyver [Fegyver hely 1/2] [Lõszer]\");
                if(ammo < 1) return SCM(playerid, COLOR_RED, \"A lõszer minimum 10db maximum 50db lehet!\");
                if(slot == 1)
                {
                if(House[id][Gun1] == 0) return SCM(playerid,COLOR_RED,\"HIBA: \"COL_WHITE\"There is no gun on this slot.\");
                if(ammo > House[id][Ammo1]) return SCM(playerid, COLOR_RED, \"EROR:\"COL_WHITE\" In the safe does not have that much ammo.\");
                GivePlayerWeapon(playerid,House[id][Gun1],ammo);
                House[id][Ammo1] -= ammo;
                if(House[id][Ammo1] == 0) {House[id][Gun1] = 0;}
                format(string,sizeof(string),\"{E0BC1B}You are take gun from slot 1.With %d ammo\",ammo);
        SCM(playerid,-1,string);
        CheckHouse(id);
        }
                if(slot == 2)
                {
                if(House[id][Gun2] == 0) return SCM(playerid,COLOR_RED,\"EROR: \"COL_WHITE\"There is no gun on this slot.\");
                if(ammo > House[id][Ammo2]) return SCM(playerid, COLOR_RED, \"EROR:\"COL_WHITE\" In the safe does not have that much ammo.\");
                GivePlayerWeapon(playerid,House[id][Gun2],ammo);
                House[id][Ammo2] -= ammo;
                if(House[id][Ammo2] == 0) {House[id][Gun2] = 0;}
                format(string,sizeof(string),\"{E0BC2B}You have taken gun from slot 2.With %d ammo\",ammo);
        SCM(playerid,-1,string);
        CheckHouse(id);
        }
                return 1;
}
YCMD:megnezszef(playerid, params[], help)
{
        #pragma unused help
        #pragma unused params
        new h = Player[playerid][Houseid];
        if(h == 999) return SCM(playerid,COLOR_RED,\"HIBA: \"COL_WHITE\"Nem vagy széf közelében!\");
        new string[128];
                format(string,sizeof(string),\"\"COL_YELLOW\"A széfben\"COL_GREEN\" %dFT van!\",House[h][Money]);
                format(string,sizeof(string),\"\"COL_YELLOW\"Fegyver hely 1 | Fegyver:\"COL_GREEN\" %d \"COL_YELLOW\"| Lõszer:\"COL_GREEN\" %d db\",House[h][Gun1],House[h][Ammo1]);
                format(string,sizeof(string),\"\"COL_YELLOW\"Fegyver hely 2 | Fegyver:\"COL_GREEN\" %d \"COL_YELLOW\"| Lõszer:\"COL_GREEN\" %d db\",House[h][Gun2],House[h][Ammo2]);
        SCM(playerid,-1,string);
                return 1;
}

 
CheckHouse-ból:
 

INI_WriteInt(File, \"Money\", House[id][Money]);
INI_WriteInt(File, \"Gun1\", House[id][Gun1]);
INI_WriteInt(File, \"Gun2\", House[id][Gun2]);
INI_WriteInt(File, \"Ammo1\", House[id][Ammo1]);
INI_WriteInt(File, \"Ammo2\", House[id][Ammo2]);

 
Bocsi, ha kicsit kavaros csak most keltem. :) Remélem segítettem és mûködik is. Heló.
[mod]Javítottam a

taget

tagre![/mod]
« Utoljára szerkesztve: 2014. augusztus 19. - 15:00:57 írta Dfoglalo »

Nem elérhető Flash

  • 5726
  • (っ◕‿◕)っ
    • Profil megtekintése
Széf probléma!
« Válasz #2 Dátum: 2014. szeptember 03. - 11:25:05 »
0 Show voters
[mod]Ha megoldódott a problémád, zárd a témát![/mod]

 

SimplePortal 2.3.7 © 2008-2024, SimplePortal