PDA

View Full Version : CreateHouse Command


Man43
22/04/2017, 08:13 PM
Hello, im using ZeroHouse system but after i did /chouse 500000 3 given me like this

Use: /chouse price intid and im already type the Price + Int id so wat's wrong here.


new Index;
CMD:chouse(playerid, params[])
{
new tmp[256];
tmp = strtok(params,Index);
new tmp2[256];
tmp2 = strtok(params,Index);
if(!strlen(tmp) || !strlen(tmp2)) return SendClientMessage(playerid,-1,"Use: /chouse [price] [intid]");
new id = strval(tmp2);
new Price = strval(tmp);
if(Price <= 0)
return SendClientMessage(playerid,-1,"Invalid house price. The house price must be between $"#MIN_HOUSE_PRICE" and $"#MAX_HOUSE_PRICE"");
CreateHouse(playerid,GetFreeHouseID(),Price,id);
SendClientMessage(playerid,-1,"House Created");
return 1;
}

EDITED: Here the #defines
#define MAX_HOUSES 10000
#define MAX_INTERIORS 10
#define MAX_DIST 10
#define MAX_HOUSE_OWNED 2
#define MIN_HOUSE_PRICE 500000
#define MAX_HOUSE_PRICE 50000000

khRamin78
23/04/2017, 03:37 AM
as i know your problem is here


new tmp[256];
tmp = strtok(params,Index);
new tmp2[256];
tmp2 = strtok(params,Index);


just use sscanf its best

if(sscanf(params,"ii",tmp,tmp2)) return SendClientMessage(bla bla bla);

and use your tmp tmp2 in order



and this is rude ! you are not checking right thing (just telling to know that)


if(Price <= 0)

// you have to change this to
if(Price < MIN_HOUSE_PRICE || Price > MAN_HOUSE_PRICE)

Man43
23/04/2017, 10:33 AM
like this?
i got errors.


new Index;
CMD:chouse(playerid, params[])
{
if(sscanf(params,"ii",tmp,tmp2)) return SendClientMessage(playerid "bla bla bla");
new tmp[256];
tmp = strtok(params,Index);
new tmp2[256];
tmp2 = strtok(params,Index);
if(!strlen(tmp) || !strlen(tmp2)) return SendClientMessage(playerid,-1,"Use: /chouse [price] [intid]");
new id = strval(tmp2);
new Price = strval(tmp);
if(Price < MIN_HOUSE_PRICE || Price > MAN_HOUSE_PRICE)
return SendClientMessage(playerid,-1,"Invalid house price. The house price must be between $"#MIN_HOUSE_PRICE" and $"#MAX_HOUSE_PRICE"");
CreateHouse(playerid,GetFreeHouseID(),Price,id);
SendClientMessage(playerid,-1,"House Created");
return 1;
}

Man43
23/04/2017, 01:26 PM
any help

khRamin78
23/04/2017, 01:31 PM
CMD:chouse(playerid,params[])
{
new tmp,tmp2;
if(sscanf(params,"ii"tmp,tmp2)) return SendClientMessage(playerid,-1,"chouse <price> <indid>");
if(tmp < MIN_HOUSE_PRICE || tmp < MAX_HOUSE_PRICE) return SendClientMessage(playerid,-1,"price limit");
CreateHouse(playerid,GetFreeHouseID(),tmp,tmp2);
SendClientMessage(playerid,-1,"House Created");
return 1;
}


easy right ?

Man43
23/04/2017, 02:38 PM
Yes Easy but i got many errors XD

C:\Users\RedRex\Desktop\LVCNR\filterscripts\H-ouse.pwn(205) : error 001: expected token: "-string end-", but found "-identifier-"
C:\Users\RedRex\Desktop\LVCNR\filterscripts\H-ouse.pwn(205) : warning 215: expression has no effect
C:\Users\RedRex\Desktop\LVCNR\filterscripts\H-ouse.pwn(205) : warning 215: expression has no effect
C:\Users\RedRex\Desktop\LVCNR\filterscripts\H-ouse.pwn(205) : error 001: expected token: ";", but found ")"
C:\Users\RedRex\Desktop\LVCNR\filterscripts\H-ouse.pwn(205) : error 029: invalid expression, assumed zero
C:\Users\RedRex\Desktop\LVCNR\filterscripts\H-ouse.pwn(205) : fatal error 107: too many error messages on one line

I Edited it to your code! and then i got this errors

[Sorry for my bad English]

new Index;
CMD:chouse(playerid,params[])
{
new tmp,tmp2;
if(sscanf(params,"ii"tmp,tmp2)) return SendClientMessage(playerid,-1,"chouse <price> <indid>");
if(tmp < MIN_HOUSE_PRICE || tmp < MAX_HOUSE_PRICE) return SendClientMessage(playerid,-1,"price limit");
CreateHouse(playerid,GetFreeHouseID(),tmp,tmp2);
SendClientMessage(playerid,-1,"House Created");
return 1;
}

Man43
23/04/2017, 02:48 PM
Yes Easy but i got many errors XD

C:\Users\RedRex\Desktop\LVCNR\filterscripts\H-ouse.pwn(205) : error 001: expected token: "-string end-", but found "-identifier-"
C:\Users\RedRex\Desktop\LVCNR\filterscripts\H-ouse.pwn(205) : warning 215: expression has no effect
C:\Users\RedRex\Desktop\LVCNR\filterscripts\H-ouse.pwn(205) : warning 215: expression has no effect
C:\Users\RedRex\Desktop\LVCNR\filterscripts\H-ouse.pwn(205) : error 001: expected token: ";", but found ")"
C:\Users\RedRex\Desktop\LVCNR\filterscripts\H-ouse.pwn(205) : error 029: invalid expression, assumed zero
C:\Users\RedRex\Desktop\LVCNR\filterscripts\H-ouse.pwn(205) : fatal error 107: too many error messages on one line

I Edited it to your code! and then i got this errors

[Sorry for my bad English]

new Index;
CMD:chouse(playerid,params[])
{
new tmp,tmp2;
if(sscanf(params,"ii"tmp,tmp2)) return SendClientMessage(playerid,-1,"chouse <price> <indid>");
if(tmp < MIN_HOUSE_PRICE || tmp < MAX_HOUSE_PRICE) return SendClientMessage(playerid,-1,"price limit");
CreateHouse(playerid,GetFreeHouseID(),tmp,tmp2);
SendClientMessage(playerid,-1,"House Created");
return 1;
}

Toroi
23/04/2017, 02:54 PM
if(sscanf(params,"ii"tmp,tmp2))

You lack a comma before tmp

Man43
23/04/2017, 03:09 PM
EDITED:- Worked but let me try it :)