Help please....SSCANF issue - Still not resolved. -
Dokins - 25.01.2012
Hello, there is an issue i'm facing with this, everytime I type /housestore money...it returns /housestore money amount..
but when I actually type the amount it returns the same message!
pawn Code:
CMD:housestore(playerid, params[])
{
if(LoggedIn[playerid] == 0) return SendClientMessage(playerid, COLOUR_GREY, "You must be logged in to use this command.");
new cashamount, string[128],function[16], sum;
new houseid = GetPlayerHouseID(playerid);
if(sscanf(params, "s[16]D", function, cashamount)) return SendClientMessage(playerid, COLOUR_GREY, "Usage: /housestore [function] Available functions: weapon(coming soon), money");
if(strcmp(function, "money", true) == 0)
{
if(sscanf(function, "d", cashamount)) return SendClientMessage(playerid, COLOUR_GREY, "Usage: /housestore money [amount]");
if(cashamount < 1 || cashamount > 500000) return SendClientMessage(playerid, COLOUR_GREY, "The amount must be between $0 and $500,000.");
if(cashamount > PlayerMoney[playerid]) return SendClientMessage(playerid, COLOUR_GREY, "You do not have this much to store.");
if(HouseOwned[playerid] == houseid)
{
printf("House Owned: %d", HouseOwned[playerid]);
sum = HouseMoney[houseid] += cashamount;
HouseSQLID[houseid] = MySQL_GetValue(HouseSQLID[houseid], "id", "houses");
MySQL_SetInteger(HouseSQLID[houseid], "HouseMoney", sum, "houses");
GivePlayerMoney(playerid, -cashamount);
printf("Cash amount %d", cashamount);
format(string, sizeof(string), "You have stored $%d in your house.", cashamount);
SendClientMessage(playerid, COLOUR_ORANGE, string);
}
}
return 1;
}
Re: Help please....SSCANF issue - Still not resolved. -
milanosie - 25.01.2012
its if(!sscanf
Otherwise it u must liturally use "d" as parameter
pawn Code:
CMD:housestore(playerid, params[])
{
if(LoggedIn[playerid] == 0) return SendClientMessage(playerid, COLOUR_GREY, "You must be logged in to use this command.");
new cashamount, string[128],function[16], sum;
new houseid = GetPlayerHouseID(playerid);
if(sscanf(params, "s[16]D", function, cashamount)) return SendClientMessage(playerid, COLOUR_GREY, "Usage: /housestore [function] Available functions: weapon(coming soon), money");
if(strcmp(function, "money", true) == 0)
{
if(!sscanf(function, "d", cashamount)) return SendClientMessage(playerid, COLOUR_GREY, "Usage: /housestore money [amount]"); //use !sscanf
if(cashamount < 1 || cashamount > 500000) return SendClientMessage(playerid, COLOUR_GREY, "The amount must be between $0 and $500,000.");
if(cashamount > PlayerMoney[playerid]) return SendClientMessage(playerid, COLOUR_GREY, "You do not have this much to store.");
if(HouseOwned[playerid] == houseid)
{
printf("House Owned: %d", HouseOwned[playerid]);
sum = HouseMoney[houseid] += cashamount;
HouseSQLID[houseid] = MySQL_GetValue(HouseSQLID[houseid], "id", "houses");
MySQL_SetInteger(HouseSQLID[houseid], "HouseMoney", sum, "houses");
GivePlayerMoney(playerid, -cashamount);
printf("Cash amount %d", cashamount);
format(string, sizeof(string), "You have stored $%d in your house.", cashamount);
SendClientMessage(playerid, COLOUR_ORANGE, string);
}
}
return 1;
}
Re: Help please....SSCANF issue - Still not resolved. -
Dokins - 25.01.2012
Still not returning correctly, although it stores the money.
Re: Help please....SSCANF issue - Still not resolved. -
milanosie - 25.01.2012
hmm let me check.. will post the edit when im done
EDIT:
try this:
I re organized it a bit. I can understand if you dont like it but its cleaner for me
pawn Code:
CMD:housestore(playerid, params[])
{
if(LoggedIn[playerid] == 0) return SendClientMessage(playerid, COLOUR_GREY, "You must be logged in to use this command.");
new cashamount, string[128],function[16], sum;
new houseid = GetPlayerHouseID(playerid);
if(sscanf(params, "s[16]D", function, cashamount)) return SendClientMessage(playerid, COLOUR_GREY, "Usage: /housestore [function] Available functions: weapon(coming soon), money");
if(strcmp(function, "money", true) == 0)
{
if(!sscanf(function, "d", cashamount))
{
if(cashamount > 1 || cashamount < 500000)
{
if(cashamount < PlayerMoney[playerid])
{
if(HouseOwned[playerid] == houseid)
{
printf("House Owned: %d", HouseOwned[playerid]);
sum = HouseMoney[houseid] += cashamount;
HouseSQLID[houseid] = MySQL_GetValue(HouseSQLID[houseid], "id", "houses");
MySQL_SetInteger(HouseSQLID[houseid], "HouseMoney", sum, "houses");
GivePlayerMoney(playerid, -cashamount);
printf("Cash amount %d", cashamount);
format(string, sizeof(string), "You have stored $%d in your house.", cashamount);
SendClientMessage(playerid, COLOUR_ORANGE, string);
}
}
else return SendClientMessage(playerid, COLOUR_GREY, "You do not have this much to store.");
}
else return SendClientMessage(playerid, COLOUR_GREY, "The amount must be between $0 and $500,000.");
}
else return SendClientMessage(playerid, COLOUR_GREY, "Usage: /housestore money [amount]"); //use !sscanf
}
return 1;
}
Re: Help please....SSCANF issue - Still not resolved. -
milanosie - 25.01.2012
hmm let me check.. will post the edit when im done
EDIT:
try this:
I re organized it a bit. I can understand if you dont like it but its cleaner for me
pawn Code:
CMD:housestore(playerid, params[])
{
if(LoggedIn[playerid] == 0) return SendClientMessage(playerid, COLOUR_GREY, "You must be logged in to use this command.");
new cashamount, string[128],function[16], sum;
new houseid = GetPlayerHouseID(playerid);
if(sscanf(params, "s[16]D", function, cashamount)) return SendClientMessage(playerid, COLOUR_GREY, "Usage: /housestore [function] Available functions: weapon(coming soon), money");
if(strcmp(function, "money", true) == 0)
{
if(!sscanf(function, "d", cashamount))
{
if(cashamount > 1 || cashamount < 500000)
{
if(cashamount < PlayerMoney[playerid])
{
if(HouseOwned[playerid] == houseid)
{
printf("House Owned: %d", HouseOwned[playerid]);
sum = HouseMoney[houseid] += cashamount;
HouseSQLID[houseid] = MySQL_GetValue(HouseSQLID[houseid], "id", "houses");
MySQL_SetInteger(HouseSQLID[houseid], "HouseMoney", sum, "houses");
GivePlayerMoney(playerid, -cashamount);
printf("Cash amount %d", cashamount);
format(string, sizeof(string), "You have stored $%d in your house.", cashamount);
SendClientMessage(playerid, COLOUR_ORANGE, string);
}
}
else return SendClientMessage(playerid, COLOUR_GREY, "You do not have this much to store.");
}
else return SendClientMessage(playerid, COLOUR_GREY, "The amount must be between $0 and $500,000.");
}
else return SendClientMessage(playerid, COLOUR_GREY, "Usage: /housestore money [amount]"); //use !sscanf
}
return 1;
}
I HATE DUBBEL POSTS
Re: Help please....SSCANF issue - Still not resolved. -
Dokins - 25.01.2012
Still not working.
Re: Help please....SSCANF issue - Still not resolved. -
milanosie - 25.01.2012
ok explain, It does store everything right? but it still shows the message?
and what is strcmp funcion money
Re: Help please....SSCANF issue - Still not resolved. -
Dokins - 25.01.2012
Compares the string.
Re: Help please....SSCANF issue - Still not resolved. -
milanosie - 25.01.2012
this maybe?
pawn Code:
CMD:housestore(playerid, params[])
{
if(LoggedIn[playerid] == 0) return SendClientMessage(playerid, COLOUR_GREY, "You must be logged in to use this command.");
new cashamount, string[128],function[16], sum;
new houseid = GetPlayerHouseID(playerid);
if(sscanf(params, "s[16]d", function, cashamount))
{
if(!sscanf(function, "d", cashamount))
{
if(cashamount > 1 || cashamount < 500000)
{
if(cashamount < PlayerMoney[playerid])
{
if(HouseOwned[playerid] == houseid)
{
printf("House Owned: %d", HouseOwned[playerid]);
sum = HouseMoney[houseid] += cashamount;
HouseSQLID[houseid] = MySQL_GetValue(HouseSQLID[houseid], "id", "houses");
MySQL_SetInteger(HouseSQLID[houseid], "HouseMoney", sum, "houses");
GivePlayerMoney(playerid, -cashamount);
printf("Cash amount %d", cashamount);
format(string, sizeof(string), "You have stored $%d in your house.", cashamount);
SendClientMessage(playerid, COLOUR_ORANGE, string);
}
}
else return SendClientMessage(playerid, COLOUR_GREY, "You do not have this much to store.");
}
else return SendClientMessage(playerid, COLOUR_GREY, "The amount must be between $0 and $500,000.");
}
else return SendClientMessage(playerid, COLOUR_GREY, "Usage: /housestore money [amount]"); //use !sscanf
}
else return SendClientMessage(playerid, COLOUR_GREY, "Usage: /housestore [function] Available functions: weapon(coming soon), money");
}
EDIT: I have no idea what you did.. Your doing it waaay different then me
Re: Help please....SSCANF issue - Still not resolved. -
Dokins - 25.01.2012
Still not working.