Help with Bank Script dini_Create will not make file
#1

I have a script that does not create a dini file to save stuff for my bank, any ideas?
I would use y_ini but I have no experience with it, if anyone could help me that would be great.

If you know a similar script like this that allows me to make bank locations in game and also requires to be in the bank to use /deposit and /withdraw. then please send me it

current code:
PHP код:
//------[Includes]--------
#include <a_samp>
#include <Dini>
#include <sscanf2>
#include <zcmd>
#include <streamer>
//------[Defines]--------
#define PlayerFile         "/bank/Accounts"
#define Banks             "/bank/Banks/%i.ini"
#define COLOR_RED         0xFF0000AA
#define COLOR_YELLOW     0xFFFF00AA
#define COLOR_GREEN       0x00FF00AA
#define MAX_BANKS 100
//------[Enums]--------
enum PLAYER_MAIN
{
    
BankCash,
    
Text3D:bLabel,
    
CP,
};
//------[Arrays]--------
new pInfo[MAX_PLAYERS][PLAYER_MAIN],
    
ExitCP,
    
BankIcon,
    
cpid[32],
    
IsInBank[MAX_PLAYERS],
    
file[100],
    
Label[128];
new 
BankInfo[MAX_BANKS][PLAYER_MAIN];
//----------------[Stocks]--------------------
stock GetLastBankID()
{
    new 
count 0;
    for(new 
i=0i<MX_BANKSi++)
    {
        
format(String,sizeof(String),banks,i);
        {
            
count++;
        }
    }
    return 
count;
}
stock Float:GetPosInFrontOfPlayer(playerid, &Float:x, &Float:yFloat:distance)
{
    new 
Float:a;
    
GetPlayerPos(playeridxya);
    switch(
IsPlayerInAnyVehicle(playerid))
    {
        case 
0GetPlayerFacingAngle(playerida);
        case 
1GetVehicleZAngle(GetPlayerVehicleID(playerid), a);
    }
    
+= (distance floatsin(-adegrees));
    
+= (distance floatcos(-adegrees));
    return 
a;
}
stock LoadBanks()
{
    new 
count 0;
    for(new 
i=0i<MAX_BANKSi++)
    {
        new 
String[250];
        
format(String,sizeof(String),Banks,i);
        if(
dini_Exists(String))
        {
            
BankInfo[i][CP] = CreateDynamicCP(dini_Float(String"BankX"),dini_Float(String"BankY"),dini_Float(String"BankZ"),1.0,dini_Int(String"World"),dini_Int(String"Interior"),-1,100.0);
            
SetPlayerMapIcon(i12dini_Float(String"BankX"),dini_Float(String"BankY"),dini_Float(String"BankZ"), 521);
            
count++;
        }
    }
    return 
printf("Total Businesses Loaded: %i",count);
}
stock UnloadBanks()
{
    for(new 
i=0i<MAX_BANKSi++)
    {
        
Delete3DTextLabel(BankInfo[i][bLabel]);
        
DestroyDynamicCP(BankInfo[i][CP]);
        
RemovePlayerMapIcon(iBankIcon);
    }
    return 
1;
}
public 
OnFilterScriptInit()
{
    
ExitCP CreateDynamicCP(2304.675537, -16.03568626.742187,1,-1,-1,-1,10.0);
    
LoadBanks();
    return 
1;
}
public 
OnFilterScriptExit()
{
    
UnloadBanks();
    return 
1;
}
public 
OnPlayerConnect(playerid)
{
    new 
name[MAX_PLAYER_NAME]; GetPlayerName(playeridnamesizeof(name)); format(file,sizeof(file),PlayerFile,name);
    if(!
dini_Exists(file))
    {
        
dini_Create(file);
        
dini_IntSet(file,"BankCash",pInfo[playerid][BankCash]);
    }
    else if(
dini_Exists(file))
    {
        
pInfo[playerid][BankCash] = dini_Int(file,"BankCash");
    }
    return 
1;
}
public 
OnPlayerEnterDynamicCP(playerid,checkpointid)
{
    for(new 
0;i<MAX_BANKS;i++)
       {
           if(
checkpointid == BankInfo[i][CP])
           {
            
cpid[playerid] = i;
            
format(file,sizeof(file),"Business/%i.ini",i);
            {
                
SetPlayerPos(playerid,2307.8965,-15.9761,26.7496);
                
SetPlayerInterior(playerid0);
                
SetPlayerVirtualWorld(playeridi);
                
SetPlayerFacingAngle(playerid280);
                
SendClientMessage(playeridCOLOR_YELLOW"Welcome to the bank! Type /bankhelp for bank commands!");
                
IsInBank[playerid] = 1;
            }
        }
    }
    if(
checkpointid == ExitCP)
    {
        
format(filesizeof(file), BanksGetPlayerVirtualWorld(playerid));
        
SetPlayerPos(playeriddini_Float(file"SpawnOutX"), dini_Float(file"SpawnOutY"), dini_Float(file"BankZ"));
        
SetPlayerFacingAngle(playeriddini_Float(file"A"));
        
SetCameraBehindPlayer(playerid);
        
SetPlayerVirtualWorld(playerid0);
        
SetPlayerInterior(playerid0);
        
IsInBank[playerid] = 0;
    }
    return 
1;
}
public 
OnPlayerDisconnect(playeridreason)
{
    new 
name[MAX_PLAYER_NAME]; GetPlayerName(playeridnamesizeof(name)); format(file,sizeof(file),PlayerFile,name);
    
dini_IntSet(file,"BankCash",pInfo[playerid][BankCash]);
    return 
1;
}
CMD:bankhelp(playerid,params[])
{
    if(
IsInBank[playerid] == 0) return SendClientMessage(playeridCOLOR_RED"You are not inside a bank!");
    
SendClientMessage(playeridCOLOR_GREEN"Bank commands: /deposit, /withdraw, /balance, /transfer");
    return 
1;
}
CMD:deposit(playeridparams[])
{
    new 
amount;
    new 
name[MAX_PLAYER_NAME]; GetPlayerName(playeridnamesizeof(name)); format(file,sizeof(file),PlayerFile,name);
    if(
IsInBank[playerid] == 0) return SendClientMessage(playeridCOLOR_RED"You are not inside a bank!");
    if(
sscanf(params"i"amount)) return SendClientMessage(playeridCOLOR_RED"/deposit [amount]");
    if(
amount GetPlayerMoney(playerid)) return SendClientMessage(playerid,COLOR_RED,"You dont have that much cash!");
    if(
amount <= 0) return SendClientMessage(playerid,COLOR_RED,"You have to add atleast $1 into the bank!");
    
GivePlayerMoney(playerid,-amount);
    
pInfo[playerid][BankCash] += amount;
    new 
string[128];
    
format(string,sizeof(string),"You have deposited: $%d",amount);
    
SendClientMessage(playerid,COLOR_GREEN,string);
    
    
dini_IntSet(file,"BankCash",pInfo[playerid][BankCash]);
    
format(string,sizeof(string),"Your new bank balance is: $%d",pInfo[playerid][BankCash]);
    
SendClientMessage(playerid,COLOR_GREEN,string);
    return 
1;
}
CMD:withdraw(playeridparams[])
{
    new 
amount;
    new 
name[MAX_PLAYER_NAME]; GetPlayerName(playeridnamesizeof(name)); format(file,sizeof(file),PlayerFile,name);
    if(
IsInBank[playerid] == 0) return SendClientMessage(playeridCOLOR_RED"You are not inside a bank!");
    if(
sscanf(params"i"amount)) return SendClientMessage(playeridCOLOR_RED"/withdraw [amount]");
     if(
amount pInfo[playerid][BankCash]) return SendClientMessage(playerid,COLOR_RED,"You dont have that much cash in the bank!");
    if(
amount <= 0) return SendClientMessage(playerid,COLOR_RED,"You have to withdraw atleast $1 from the bank!");
    if(
pInfo[playerid][BankCash] == 0) return SendClientMessage(playerid,COLOR_RED,"You dont have money in the bank!");
    
    
GivePlayerMoney(playerid,amount);
    
pInfo[playerid][BankCash] -= amount;
    new 
string[128];
    
format(string,sizeof(string),"You have withdrawn: $%d",amount);
    
SendClientMessage(playerid,COLOR_GREEN,string);
    
dini_IntSet(file,"BankCash",pInfo[playerid][BankCash]);
    
format(string,sizeof(string), "Your new balance is: $%d",pInfo[playerid][BankCash]);
    
SendClientMessage(playerid,COLOR_GREEN,string);
    return 
1;
}
CMD:transfer(playeridparams[])
{
       new 
targetamount;
    new 
name[MAX_PLAYER_NAME], TargetName[MAX_PLAYER_NAME]; GetPlayerName(playeridnamesizeof(name)); GetPlayerName(targetTargetNamesizeof(name)); format(file,sizeof(file),PlayerFile,name);
    if(
sscanf(params"ui"targetamount)) return SendClientMessage(playeridCOLOR_RED"/transfer [player] [amount]");
    if(
amount <= 0) return SendClientMessage(playerid,COLOR_RED,"You have to transfer atleast $1!");
    if(
amount pInfo[playerid][BankCash]) return SendClientMessage(playerid,COLOR_RED,"You dont have that much cash in the bank!");
    if(!
IsPlayerConnected(target)) return SendClientMessage(playeridCOLOR_RED"ERROR: Player is not connected");
    if(
IsInBank[playerid] == 0) return SendClientMessage(playeridCOLOR_RED"You are not inside a bank!");
    new 
string[128];
    
pInfo[playerid][BankCash] -= amount;
    
pInfo[target][BankCash] += amount;
    
    
format(string,sizeof(string),"You have transfered $%d to %s's bank account.",amount,TargetName);
    
SendClientMessage(playerid,COLOR_GREEN,string);
    
    
dini_IntSet(file,"BankCash",pInfo[playerid][BankCash]);
    
format(string,sizeof(string),"Your new balance is $%d",pInfo[playerid][BankCash]);
    
SendClientMessage(playerid,COLOR_GREEN,string);
    
    
format(string,sizeof(string),"%s has deposited $%d into your bank account.",name,amount);
    
SendClientMessage(target,COLOR_GREEN,string);
    
    
format(string,sizeof(string),"Your new bank balance is: $%d",pInfo[target][BankCash]);
    
SendClientMessage(target,COLOR_GREEN,string);
    return 
1;
}
CMD:balance(playeridparams[])
{
    new 
string[128];
    
format(string,sizeof(string),"Your current balance is: Hand: $%d. Bank: $%d. Total: $%d.",GetPlayerMoney(playerid), pInfo[playerid][BankCash], GetPlayerMoney(playerid)+pInfo[playerid][BankCash]);
    
SendClientMessage(playeridCOLOR_GREENstring);
    return 
1;
}
CMD:createbank(playeridparams[])
{
    new 
bankid,
         
Float:x,Float:y,
         
Float:X,Float:Y,Float:Z,
         
string[128];
         
    if(!
IsPlayerAdmin(playerid)) return 0;
    for(new 
i=0i<MAX_BANKSi++)
    {
         
format(file,sizeof(file),Banks,i);
         if(!
dini_Exists(file))
         {
             
bankid i;
             break;
         }
    }
     
format(file,sizeof(file),Banks,bankid);
    
GetPlayerPos(playeridXYZ);
    
GetPosInFrontOfPlayer(playeridxy, -2.5);
    
dini_Create(file);
    
dini_FloatSet(file"BankX"X);
    
dini_FloatSet(file"BankY"Y);
    
dini_FloatSet(file"BankZ"Z);
    
dini_FloatSet(file"SpawnOutX"x);
    
dini_FloatSet(file"SpawnOutY"y);
    
dini_FloatSet(file"SpawnOutZ"Z);
    
dini_IntSet(file"World",GetPlayerVirtualWorld(playerid));
    
dini_IntSet(file"Interior",GetPlayerInterior(playerid));
     
format(Label,sizeof(Label),"Bank",bankid);
     
BankIcon SetPlayerMapIcon(playerid12XYZ521);
    
BankInfo[bankid][CP] = CreateDynamicCP(X,Y,Z,1.0,GetPlayerVirtualWorld(playerid),GetPlayerInterior(playerid),-1,50.0);
    
BankInfo[bankid][bLabel] = Create3DTextLabel(Label,COLOR_GREEN,X,Y,Z,100.0,GetPlayerVirtualWorld(playerid),1);
    
format(string,sizeof(string), "Created bank ID: %i.",bankid);
    
SendClientMessage(playeridCOLOR_GREENstring);
    return 
1;
}
CMD:deletebank(playeridparams[])
{
    new 
bankid,
        
String[148];
    if(!
IsPlayerAdmin(playerid)) return 0;
    if(
sscanf(params"i"bankid)) return SendClientMessage(playerid,COLOR_RED,"Usage: /deletebank [bankid]");
    
format(file,sizeof(file),Banks,bankid);
    if(!
dini_Exists(file))return SendClientMessage(playerid,COLOR_RED,"That bankID does not exists.");
    
format(String,sizeof(String),"You have successfully deleted a bank. ID: %i.",bankid);
    
SendClientMessage(playerid,COLOR_RED,String);
    
DestroyDynamicCP(BankInfo[bankid][CP]);
    
Delete3DTextLabel(BankInfo[bankid][bLabel]);
    
RemovePlayerMapIcon(playeridBankIcon);
    
dini_Remove(file);
    return 
1;

Reply
#2

I can give you an easy solution. Convert to Y_INI. That is the fastest most reliable saving system out at the moment.
Reply
#3

Quote:
Originally Posted by zDivine
Посмотреть сообщение
I can give you an easy solution. Convert to Y_INI. That is the fastest most reliable saving system out at the moment.
I would if I knew how to
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)