Simple help
#1

PHP код:
CMD:savecash(playeridparams[])
{
    if (
playeritems[playerid][ITEM_TYPE_Breifcase] == 0) return SendClientMessage2(playeridCOLOR_RED"You don't have a breifcase buy it from nearest store!");
    new 
cash;
    if(
sscanf(params"d"cash)) return SendClientMessage(playeridCOLOR_WHITE"Usage: /savecash [Amount]");
    new 
pcash GetPlayerMoney(playerid);
    if(
pcash cash) return SendClientMessage(playeridCOLOR_RED"Error: You don't have that amount!");
    new 
name[26];
    
GetPlayerName(playeridname26);
    
dini_IntSet(AddDirFile(dir_userfilesname), "Briefcasecash"cash);
    
GivePlayerMoney(playerid, -cash);
    new 
string[256];
    
format(stringsizeof(string), "You have deposited %d from your briefcase. You have now %d"cashdini_Int(AddDirFile(dir_userfilesname), "Briefcasecash"));
    
SendClientMessage(playeridCOLOR_YELLOWstring);
    return 
1;
}
CMD:getbccash(playeridparams[])
{
    if (
playeritems[playerid][ITEM_TYPE_Breifcase] == 0) return SendClientMessage2(playeridCOLOR_RED"You don't have a breifcase buy it from nearest store!");
    new 
cash;
    new 
name[MAX_PLAYER_NAME];
    if(
sscanf(params"d"cash)) return SendClientMessage(playeridCOLOR_WHITE"Usage: /getcash [Amount]");
    if(
dini_Int(AddDirFile(dir_userfilesname), "Briefcasecash") < cash) return SendClientMessage(playeridCOLOR_RED"Error: You don't have that amount!");
    
dini_IntSet(AddDirFile(dir_userfilesname), "Briefcasecash"dini_Int(AddDirFile(dir_userfilesname), "Briefcasecash") - cash);
    
GivePlayerMoney(playeridcash);
    new 
string[256];
    
format(stringsizeof(string), "You have Withdrawn %d from your briefcase. You have now %d"cashdini_Int(AddDirFile(dir_userfilesname), "Briefcasecash"));
    
SendClientMessage(playeridCOLOR_YELLOWstring);
    return 
1;

i created this cmds to savecash and get the cash
after typng /savecash it saving the cash but when i do /getcash its saying You dont have that amount
pls help me


and i want to add
#define max_cash 20000
pls help me
Reply
#2

please help
Reply
#3

Not sure but give a try

Код:
CMD:savecash(playerid, params[])
{
    if (playeritems[playerid][ITEM_TYPE_Breifcase] == 0) return SendClientMessage2(playerid, COLOR_RED, "You don't have a breifcase buy it from nearest store!");
    new cash;
    if(sscanf(params, "d", cash)) return SendClientMessage(playerid, COLOR_WHITE, "Usage: /savecash [Amount]");
    new pcash = GetPlayerMoney(playerid);
    if(pcash < cash) return SendClientMessage(playerid, COLOR_RED, "Error: You don't have that amount!");
    new name[26];
    GetPlayerName(playerid, name, 26);
    dini_IntSet(AddDirFile(dir_userfiles, name), "Briefcasecash", cash);
    GivePlayerMoney(playerid, -cash);
    new string[256];
    format(string, sizeof(string), "You have deposited %d from your briefcase. You have now %d", cash, dini_Int(AddDirFile(dir_userfiles, name), "Briefcasecash"));
    SendClientMessage(playerid, COLOR_YELLOW, string);
    return 1;
}
CMD:getbccash(playerid, params[])
{
    if (playeritems[playerid][ITEM_TYPE_Breifcase] == 0) return SendClientMessage2(playerid, COLOR_RED, "You don't have a breifcase buy it from nearest store!");
    new cash;
    new name[MAX_PLAYER_NAME];
    if(sscanf(params, "d", cash)) return SendClientMessage(playerid, COLOR_WHITE, "Usage: /getcash [Amount]");
    if(dini_Int(AddDirFile(dir_userfiles, name), "Briefcasecash" < cash) return SendClientMessage(playerid, COLOR_RED, "Error: You don't have that amount!");
    dini_IntSet(AddDirFile(dir_userfiles, name), "Briefcasecash", dini_Int(AddDirFile(dir_userfiles, name), "Briefcasecash") -cash);
    GivePlayerMoney(playerid, cash);
    new string[256];
    format(string, sizeof(string), "You have Withdrawn %d from your briefcase. You have now %d", cash, dini_Int(AddDirFile(dir_userfiles, name), "Briefcasecash"));
    SendClientMessage(playerid, COLOR_YELLOW, string);
    return 1;
}
Reply
#4

not working pls help me
Reply
#5

help me i need help pls
Reply
#6

Under:
CMD:getbccash(playerid, params[])

new name[MAX_PLAYER_NAME];

You are missing this dear friend:
GetPlayerName(playerid, name, 26); // MAX_PLAYER_NAME has 24 characters, not 26 though.

Also just an advice, dont write this under your signature:
Scripting Systems/Commands In Money$

If you have no freaking clue how to fix your own code.
Reply
#7

Quote:
Originally Posted by whadez
Посмотреть сообщение
Under:
CMD:getbccash(playerid, params[])

new name[MAX_PLAYER_NAME];

You are missing this dear friend:
GetPlayerName(playerid, name, 26); // MAX_PLAYER_NAME has 24 characters, not 26 though.

Also just an advice, dont write this under your signature:
Scripting Systems/Commands In Money$

If you have no freaking clue how to fix your own code.
by the way i want to fix /savecash to
its saving the cash after doing /savecash but when i type and save another amount its not adding in old one its
cutting my all money and setting it to taht much in last u saved so pls help me and i want to make this cod ewith

MAX_CASH 20000
so please help me in this ok

PHP код:
CMD:savecash(playeridparams[])
{
    if (
playeritems[playerid][ITEM_TYPE_Breifcase] == 0) return SendClientMessage2(playeridCOLOR_RED"You don't have a breifcase buy it from nearest store!");
    new 
cash;
    if(
sscanf(params"d"cash)) return SendClientMessage(playeridCOLOR_WHITE"Usage: /savecash [Amount]");
    new 
pcash GetPlayerMoney(playerid);
    if(
pcash cash) return SendClientMessage(playeridCOLOR_RED"Error: You don't have that amount!");
    new 
name[26];
    
GetPlayerName(playeridname26);
    
dini_IntSet(AddDirFile(dir_userfilesname), "Briefcasecash"cash);
    
GivePlayerMoney(playerid, -cash);
    new 
string[256];
    
format(stringsizeof(string), "You have deposited %d from your briefcase. You have now %d"cashdini_Int(AddDirFile(dir_userfilesname), "Briefcasecash"));
    
SendClientMessage(playeridCOLOR_YELLOWstring);
    return 
1;
}
CMD:getbccash(playeridparams[])
{
    if (
playeritems[playerid][ITEM_TYPE_Breifcase] == 0) return SendClientMessage2(playeridCOLOR_RED"You don't have a breifcase buy it from nearest store!");
    new 
cash;
    new 
name[26];
    
GetPlayerName(playeridname26);
    if(
sscanf(params"d"cash)) return SendClientMessage(playeridCOLOR_WHITE"Usage: /getbccash [Amount]");
    if(
dini_Int(AddDirFile(dir_userfilesname), "Briefcasecash") < cash) return SendClientMessage(playeridCOLOR_RED"Error: You don't have that amount!");
    
dini_IntSet(AddDirFile(dir_userfilesname), "Briefcasecash"dini_Int(AddDirFile(dir_userfilesname), "Briefcasecash") - cash);
    
GivePlayerMoney(playeridcash);
    new 
string[256];
    
format(stringsizeof(string), "You have Withdrawn %d from your briefcase. You have now %d"cashdini_Int(AddDirFile(dir_userfilesname), "Briefcasecash"));
    
SendClientMessage(playeridCOLOR_YELLOWstring);
    return 
1;

Reply
#8

Quote:
Originally Posted by GoldenMan
Посмотреть сообщение
by the way i want to fix /savecash to
its saving the cash after doing /savecash but when i type and save another amount its not adding in old one its
cutting my all money and setting it to taht much in last u saved so pls help me and i want to make this cod ewith

MAX_CASH 20000
so please help me in this ok

PHP код:
CMD:savecash(playeridparams[])
{
    if (
playeritems[playerid][ITEM_TYPE_Breifcase] == 0) return SendClientMessage2(playeridCOLOR_RED"You don't have a breifcase buy it from nearest store!");
    new 
cash;
    if(
sscanf(params"d"cash)) return SendClientMessage(playeridCOLOR_WHITE"Usage: /savecash [Amount]");
    new 
pcash GetPlayerMoney(playerid);
    if(
pcash cash) return SendClientMessage(playeridCOLOR_RED"Error: You don't have that amount!");
    new 
name[26];
    
GetPlayerName(playeridname26);
    
dini_IntSet(AddDirFile(dir_userfilesname), "Briefcasecash"cash);
    
GivePlayerMoney(playerid, -cash);
    new 
string[256];
    
format(stringsizeof(string), "You have deposited %d from your briefcase. You have now %d"cashdini_Int(AddDirFile(dir_userfilesname), "Briefcasecash"));
    
SendClientMessage(playeridCOLOR_YELLOWstring);
    return 
1;
}
CMD:getbccash(playeridparams[])
{
    if (
playeritems[playerid][ITEM_TYPE_Breifcase] == 0) return SendClientMessage2(playeridCOLOR_RED"You don't have a breifcase buy it from nearest store!");
    new 
cash;
    new 
name[26];
    
GetPlayerName(playeridname26);
    if(
sscanf(params"d"cash)) return SendClientMessage(playeridCOLOR_WHITE"Usage: /getbccash [Amount]");
    if(
dini_Int(AddDirFile(dir_userfilesname), "Briefcasecash") < cash) return SendClientMessage(playeridCOLOR_RED"Error: You don't have that amount!");
    
dini_IntSet(AddDirFile(dir_userfilesname), "Briefcasecash"dini_Int(AddDirFile(dir_userfilesname), "Briefcasecash") - cash);
    
GivePlayerMoney(playeridcash);
    new 
string[256];
    
format(stringsizeof(string), "You have Withdrawn %d from your briefcase. You have now %d"cashdini_Int(AddDirFile(dir_userfilesname), "Briefcasecash"));
    
SendClientMessage(playeridCOLOR_YELLOWstring);
    return 
1;

you should load the existing data ,add it up with data you providing and save
stop using file based system start using SQL for data transaction
Reply
#9

Quote:
Originally Posted by SyS
Посмотреть сообщение
you should load the existing data ,add it up with data you providing and save
stop using file based system start using SQL for data transaction
my script based on Dini so i cant use the sql ok
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)