Help with Bank
#1

pawn Код:
#include <a_samp>
#include <Dini>
#include <dudb>
#include <streamer>
#include <zcmd>
#include <sscanf2>

new pname[MAX_PLAYER_NAME];
new banklogged[MAX_PLAYERS];
new bankmoney[MAX_PLAYERS];
#define COLOR_RED 0xFF0000AA
#define COLOR_YELLOW 0xFFFF00AA
#define COLOR_GREEN 0x00FF00AA

new GetinBank;
new GetoutBank;
new GetinBank1;
new Bank1[MAX_PLAYERS];
new Bank2[MAX_PLAYERS];
new Withdraw;
new deposit;
new createaccount;
new loginaccount;
new balance;

public OnFilterScriptInit()
{
 GetinBank = CreatePickup(1318, 1, 1481.283813, -1770.431152, 18.795755, 0);
GetoutBank = CreatePickup(1318, 1, 2304.675537, -16.035686, 26.742187, 0);
GetinBank1 = CreatePickup(1318, 1, 2474.7058,1023.5376,10.8203, 0);
createaccount = CreatePickup(1239,1,2316.6199,-15.5360,26.7422,-1);
loginaccount = CreatePickup(1239,1,2316.6213,-12.5825,26.7422,-1);
Withdraw = CreatePickup(1239,1,2316.6208,-9.9430,26.7422,-1);
deposit = CreatePickup(1239,1,2316.6089,-7.2970,26.7422,-1);
balance = CreatePickup(1239,1,2316.6208,-4.7285,26.7422,-1);
 print("/////////////////////////////////////////");
 print("//   SIMPLE BANK SYSTEM BY SEAN5874   //");
 print("//    Releasedate: 04-04-10           //");
 print("///////////////////////////////////////");
 return 1;
}

public OnFilterScriptExit()
{
 return 1;
}

public OnPlayerDisconnect(playerid, reason)
{
    dini_IntSet(udb_encode(pname), "bankmoney", bankmoney[playerid]);
 return 1;
}
public OnPlayerCommandText(playerid, cmdtext[])
{

    return 0;
}
public OnPlayerPickUpPickup(playerid,pickupid)
{
if(pickupid == GetinBank)
{
SetPlayerPos(playerid, 2315.952880,-1.618174,26.742187);
SendClientMessage(playerid,0xD6D6D6AA,"Type /bank");
SetCameraBehindPlayer(playerid);
Bank1[playerid] = 1;
}
if(pickupid == GetoutBank)
{
if(Bank1[playerid] == 1)
{
SetPlayerPos(playerid,1481.130371,-1763.401000, 18.795755);
SetPlayerFacingAngle(playerid,0.0);
SetCameraBehindPlayer(playerid);
}
if(Bank2[playerid] == 1)
SetPlayerPos(playerid,2475.4209,1019.2725,10.8203);
SetPlayerFacingAngle(playerid,0.0);
SetCameraBehindPlayer(playerid);
}
if(pickupid == GetinBank1)
{
SetPlayerPos(playerid,2315.952880,-1.618174,26.742187);
SendClientMessage(playerid,0xD6D6D6AA,"Type /bank");
SetCameraBehindPlayer(playerid);
Bank2[playerid] = 1;
}
if(pickupid == Bank)
{
ShowPlayerDialog(playerid,22,DIALOG_STYLE_LIST,"Bank","Create an Account\n Login your debit Card\n Withdraw your Cash\n Deposit your cash\n Look at your bank balance","Select","Exit");
return 1;
}

public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
if(dialogid == 22 && response == 1)
{
switch(listitem)
{
case 0:
new idx, tmp[265], tmp2[256];
{
   new pincode; //creating the variable
  tmp = strtok(cmdtext, idx);
  if(banklogged[playerid] == 1) //checks if a player is logged in in his account
  {
      ShowPlayerDialog(playerid,24,DIALOG_STYLE_MSGBOX,"Already logged in","You are already logged in with your debit Card","Okay","");
      return 1;
  }
  pincode = strval(tmp); //'pincode' got saved in an TMP
  tmp2 = dini_Get(udb_encode(pname), "pincode"); //gets the pincode that is given by creating the account
  if (udb_hash(tmp) != strval(tmp2)) //looks of the given pincode match with the pincode in the file
  {
   ShowPlayerDialog(playerid,24,DIALOG_STYLE_MSGBOX,"Wrong Password","You have entered a wrong password of your debit card","Okay","");
   return 1;
  }
  }
  ShowPlayerDialog(playerid,24,DIALOG_STYLE_MSGBOX,"Congratulations","You are now logged in with your debit card");
  }
  }
  case 1:
  {
new idx, tmp[265], tmp2[256];
{
   new pincode; //creating the variable
  tmp = strtok(cmdtext, idx);
  if(banklogged[playerid] == 1) //checks if a player is logged in in his account
  {
      ShowPlayerDialog(playerid,24,DIALOG_STYLE_MSGBOX,"Already logged in","You are already logged in with your debit Card","Okay",""); return 1;
  }
  pincode = strval(tmp); //'pincode' got saved in an TMP
  tmp2 = dini_Get(udb_encode(pname), "pincode"); //gets the pincode that is given by creating the account
  if (udb_hash(tmp) != strval(tmp2)) //looks of the given pincode match with the pincode in the file
  {
   ShowPlayerDialog(playerid,24,DIALOG_STYLE_MSGBOX,"Wrong Password","You have entered a wrong password of your debit card","Okay","");
   return 1;
  }
  ShowPlayerDialog(playerid,24,DIALOG_STYLE_MSGBOX,"Congratulations","You are now logged in with your debit card","Okay","");
  banklogged[playerid] = 1;
  }
  }
  case 2:
  {
new idx, tmp[265], tmp2[256];
{
  new wamount; //creating the variable
   tmp = strtok(cmdtext, idx);
  if(banklogged[playerid] == 0) // checks if a player is logged in in his account
  {
      ShowPlayerDialog(playerid,24,DIALOG_STYLE_MSGBOX,"Not logged in","You are not logged in with your debit card"); return 1;
  }
  wamount = strval(tmp); //'wamount' got saved in an TMP

  new bank = bankmoney[playerid];
  if(bank <= wamount) // if a player tries to withdraw more money than he haves on his account...
  {
    ShowPlayerDialog(playerid,24,DIALOG_STYLE_MSGBOX,"Withdrawning","You can't withdraw more money you have"); return 1;
  }
   bankmoney[playerid] -= wamount; //money is taken from the bank account
   format(string, sizeof(string), "You have withdrawed $%d to your bank account.",wamount); // show the amount of withdrawed money
   SendClientMessage(playerid,0xD6D6D6AA,string);
   GivePlayerMoney(playerid, wamount);// gives the player his money
  }
  }
 }
 }
  }
  case 3:
  {
new idx, tmp[265], tmp2[256];
{
  new amount; //creating the variable
  tmp = strtok(cmdtext, idx);
  if(banklogged[playerid] == 0) //checks if a player is logged in in his account
  {
      ShowPlayerDialog(playerid,34,DIALOG_STYLE_MSGBOX,"Not logged in","You are not logged in with your debit card"); return 1;
  }
  amount = strval(tmp); //'amount' got saved in an TMP

  new currentm = GetPlayerMoney(playerid);
  if(currentm <= amount) //checks if the players current money is lower than the amount he want to deposit
  {
     ShowPlayerDialog(playerid,24,DIALOG_STYLE_MSGBOX,"Depositing","You can't deposit more money you have"); return 1;
  }
   bankmoney[playerid] += amount; //money goes on the bank account
   format(string, sizeof(string), "You have deposited $%d to your bank account.",amount);
   SendClientMessage(playerid, COLOR_YELLOW, string);
   GivePlayerMoney(playerid, -amount);
   }
   }
  case 4:
  {
  new string[128];
 {
  if(banklogged[playerid] == 0) //checks if a player is logged in in his account
  {
      ShowPlayerDialog(playerid,84,DIALOG_STYLE_MSGBOX,"Not logged in","You are not logged in with your debit card"); return 1;
  }
   format(string, sizeof(string), "You have currently $%d in your bank account.",bankmoney[playerid]); //show the amount of money on the account
   SendClientMessage(playerid, COLOR_YELLOW, string);
   }
   }
   }
   }
   return 0;
  }
First, i did only case 0: then i got some errors when i done all, Then i get a don't send error, and I know why its coming dont send error because i would did a big mistake, thats why, can you guys fix this script, i editted this filterscript in dialogs.
Reply
#2

Can anyone help me with it?
Reply
#3

Can anyone fucking reply? It's taking alot of time
Reply
#4

Can anoyone reply pleaseeeeeeeeeeeeeee?
Reply
#5

Man just wait for another's reply, you bump during the time :\
Reply
#6

Here's your code with some shitty errors:
pawn Код:
#include <a_samp>
#include <Dini>
#include <dudb>
#include <streamer>
#include <zcmd>
#include <sscanf2>

new pname[MAX_PLAYER_NAME];
new banklogged[MAX_PLAYERS];
new bankmoney[MAX_PLAYERS];
#define COLOR_RED 0xFF0000AA
#define COLOR_YELLOW 0xFFFF00AA
#define COLOR_GREEN 0x00FF00AA

new GetinBank;
new GetoutBank;
new GetinBank1;
new Bank1[MAX_PLAYERS];
new Bank2[MAX_PLAYERS];
new Withdraw;
new deposit;
new createaccount;
new loginaccount;
new balance;

public OnFilterScriptInit()
{
    GetinBank = CreatePickup(1318, 1, 1481.283813, -1770.431152, 18.795755, 0);
    GetoutBank = CreatePickup(1318, 1, 2304.675537, -16.035686, 26.742187, 0);
    GetinBank1 = CreatePickup(1318, 1, 2474.7058,1023.5376,10.8203, 0);
    createaccount = CreatePickup(1239,1,2316.6199,-15.5360,26.7422,-1);
    loginaccount = CreatePickup(1239,1,2316.6213,-12.5825,26.7422,-1);
    Withdraw = CreatePickup(1239,1,2316.6208,-9.9430,26.7422,-1);
    deposit = CreatePickup(1239,1,2316.6089,-7.2970,26.7422,-1);
    balance = CreatePickup(1239,1,2316.6208,-4.7285,26.7422,-1);
    print("/////////////////////////////////////////");
    print("//   SIMPLE BANK SYSTEM BY SEAN5874   //");
    print("//    Releasedate: 04-04-10           //");
    print("///////////////////////////////////////");
    return 1;
}


public OnFilterScriptExit()
{
    return 1;
}


public OnPlayerDisconnect(playerid, reason)
{
    dini_IntSet(udb_encode(pname), "bankmoney", bankmoney[playerid]);
    return 1;
}

public OnPlayerPickUpPickup(playerid,pickupid)
{
    if(pickupid == GetinBank)
    {
        SetPlayerPos(playerid, 2315.952880,-1.618174,26.742187);
        SendClientMessage(playerid,0xD6D6D6AA,"Type /bank");
        SetCameraBehindPlayer(playerid);
        Bank1[playerid] = 1;
    }
    if(pickupid == GetoutBank)
    {
        if(Bank1[playerid] == 1)
        {
            SetPlayerPos(playerid,1481.130371,-1763.401000, 18.795755);
            SetPlayerFacingAngle(playerid,0.0);
            SetCameraBehindPlayer(playerid);
        }
        if(Bank2[playerid] == 1)
        {
            SetPlayerPos(playerid,2475.4209,1019.2725,10.8203);
            SetPlayerFacingAngle(playerid,0.0);
            SetCameraBehindPlayer(playerid);
        }
    }
    if(pickupid == GetinBank1)
    {
        SetPlayerPos(playerid,2315.952880,-1.618174,26.742187);
        SendClientMessage(playerid,0xD6D6D6AA,"Type /bank");
        SetCameraBehindPlayer(playerid);
        Bank2[playerid] = 1;
    }
    if(pickupid == Bank)
    {
        ShowPlayerDialog(playerid,22,DIALOG_STYLE_LIST,"Bank","Create an Account\n Login your debit Card\n Withdraw your Cash\n Deposit your cash\n Look at your bank balance","Select","Exit");
        return 1;
    }
    return 0;
}

public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[]) {
{
    new idx, tmp[64], tmp2[64];
    if(dialogid == 22 && response == 1)
        {
            switch(listitem)
            {
                case 0:
                    {
                        new pincode;//creating the variable
                        tmp = strtok(cmdtext, idx);//checks if a player is logged in in his account
                        if(banklogged[playerid] == 1)
                        {
                            ShowPlayerDialog(playerid,24,DIALOG_STYLE_MSGBOX,"Already logged in","You are already logged in with your debit Card","Okay","");
                            return 1;
                        }
                        pincode = strval(tmp);//'pincode' got saved in an TMP
                        tmp2 = dini_Get(udb_encode(pname), "pincode");//gets the pincode that is given by creating the account
                        if (udb_hash(tmp) != strval(tmp2))//looks of the given pincode match with the pincode in the file
                        {
                            ShowPlayerDialog(playerid,24,DIALOG_STYLE_MSGBOX,"Wrong Password","You have entered a wrong password of your debit card","Okay","");
                            return 1;
                        }
                        else
                        {
                            ShowPlayerDialog(playerid,24,DIALOG_STYLE_MSGBOX,"Congratulations","You are now logged in with your debit card");
                        }
                    }

                case 1:
                {
                    {
                        new pincode;                      //creating the variable
                        tmp = strtok(cmdtext, idx);
                        if(banklogged[playerid] == 1)
                        {   //checks if a player is logged in in his account
                            ShowPlayerDialog(playerid,24,DIALOG_STYLE_MSGBOX,"Already logged in","You are already logged in with your debit Card","Okay",""); return 1;
                        }
                        pincode = strval(tmp);            //'pincode' got saved in an TMP
                                                          //gets the pincode that is given by creating the account
                        tmp2 = dini_Get(udb_encode(pname), "pincode");
                                                          //looks of the given pincode match with the pincode in the file
                        if (udb_hash(tmp) != strval(tmp2))
                        {
                            ShowPlayerDialog(playerid,24,DIALOG_STYLE_MSGBOX,"Wrong Password","You have entered a wrong password of your debit card","Okay","");
                            return 1;
                        }
                        ShowPlayerDialog(playerid,24,DIALOG_STYLE_MSGBOX,"Congratulations","You are now logged in with your debit card","Okay","");
                        banklogged[playerid] = 1;
                    }
                }
                case 2:
                {
                    {
                        new wamount;                      //creating the variable
                        tmp = strtok(cmdtext, idx);
                        if(banklogged[playerid] == 0)
                        {   // checks if a player is logged in in his account
                            ShowPlayerDialog(playerid,24,DIALOG_STYLE_MSGBOX,"Not logged in","You are not logged in with your debit card"); return 1;
                        }
                        wamount = strval(tmp);            //'wamount' got saved in an TMP

                        new bank = bankmoney[playerid];
                        if(bank <= wamount)
                        {             // if a player tries to withdraw more money than he haves on his account...
                            ShowPlayerDialog(playerid,24,DIALOG_STYLE_MSGBOX,"Withdrawning","You can't withdraw more money you have"); return 1;
                        }
                        bankmoney[playerid] -= wamount;   //money is taken from the bank account
                                                          // show the amount of withdrawed money
                        format(string, sizeof(string), "You have withdrawed $%d to your bank account.",wamount);
                        SendClientMessage(playerid,0xD6D6D6AA,string);
                                                          // gives the player his money
                        GivePlayerMoney(playerid, wamount);
                    }
                }
                case 3:
                {
                    {
                        new amount;                               //creating the variable
                        tmp = strtok(cmdtext, idx);
                        if(banklogged[playerid] == 0) {           //checks if a player is logged in in his account
                            ShowPlayerDialog(playerid,34,DIALOG_STYLE_MSGBOX,"Not logged in","You are not logged in with your debit card"); return 1;
                        }
                        amount = strval(tmp);                     //'amount' got saved in an TMP

                        new currentm = GetPlayerMoney(playerid);
                        if(currentm <= amount) {                  //checks if the players current money is lower than the amount he want to deposit
                            ShowPlayerDialog(playerid,24,DIALOG_STYLE_MSGBOX,"Depositing","You can't deposit more money you have"); return 1;
                        }
                        bankmoney[playerid] += amount;            //money goes on the bank account
                        format(string, sizeof(string), "You have deposited $%d to your bank account.",amount);
                        SendClientMessage(playerid, COLOR_YELLOW, string);
                        GivePlayerMoney(playerid, -amount);
                    }
                }
                case 4:
                {
                    new string[128];
                    {
                        if(banklogged[playerid] == 0) {           //checks if a player is logged in in his account
                            ShowPlayerDialog(playerid,84,DIALOG_STYLE_MSGBOX,"Not logged in","You are not logged in with your debit card"); return 1;
                        }
                                                                  //show the amount of money on the account
                        format(string, sizeof(string), "You have currently $%d in your bank account.",bankmoney[playerid]);
                        SendClientMessage(playerid, COLOR_YELLOW, string);
                    }
                }
            }
        }
        return 0;
}
First suggestion re-write the OnDialogResponse after learning scripting!
How the hell you are using cmdtext under this callback!
Just go off to learn how to script!
The last thing try to be patient and try to solve your problem yourself instead of bumping.
The min. hours for bumping is 48.

Wish you luck for your problematic scripting skill.
Reply
#7

I dunno why you are using "tmp = strtok(cmdtext, idx);" in the Dialogs Response callback.
Use "inputtext[]" instead.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)