/createhouse <address> not working
#1

Why isn't the address working? I want it so if I type an example:

Код:
/createhouse 214 Los Santos
Here is my script:

pawn Код:
CMD:createhouse(playerid, params[])
{
    new string[128], Float:x, Float:y, Float:z;
    GetPlayerPos(playerid, x, y, z);
    if(sscanf(params, "s[512]", params)) return SendClientMessage(playerid, -1, ""Grey"Syntax"White": /createhouse [address].");
    for(new houseid=1; houseid<MAX_HOUSES; houseid++)
    {
        HouseInfo[houseid][hID] = houseid;
        format(HouseInfo[houseid][hAddress], 30, "%s", params);
        format(HouseInfo[houseid][hOwner], 32, "None");
        HouseInfo[houseid][hOwned] = 0;
        HouseInfo[houseid][hPickUp] = CreateDynamicPickup(1273, 1, x, y, z, 0);
        format(string, sizeof(string), ""Green"ID: %d\nHouse Address: %s", houseid, HouseInfo[houseid][hAddress]);
        HouseInfo[houseid][hText] = CreateDynamic3DTextLabel(string, -1, x, y, z, 20.0);
        houseid = MAX_HOUSES;
    }
    return 1;
}
Reply
#2

U need to hold the "Params" into something else.
E.g new variable
Reply
#3

Try this:
pawn Код:
CMD:createhouse(playerid, params[])
{
    new string[128], Float:x, Float:y, Float:z, houseadr[128];
    GetPlayerPos(playerid, x, y, z);
    if(sscanf(params, "s[128]", houseadr)) return SendClientMessage(playerid, -1, ""Grey"Syntax"White": /createhouse [address].");
    for(new houseid=1; houseid<MAX_HOUSES; houseid++)
    {
        HouseInfo[houseid][hID] = houseid;
        format(HouseInfo[houseid][hAddress], 30, "%s", params);
        format(HouseInfo[houseid][hOwner], 32, "None");
        HouseInfo[houseid][hOwned] = 0;
        HouseInfo[houseid][hPickUp] = CreateDynamicPickup(1273, 1, x, y, z, 0);
        format(string, sizeof(string), ""Green"ID: %d\nHouse Address: %s", houseid, HouseInfo[houseid][hAddress]);
        HouseInfo[houseid][hText] = CreateDynamic3DTextLabel(string, -1, x, y, z, 20.0);
        houseid = MAX_HOUSES;
    }
    return 1;
}
Reply
#4

Is there a little example you could give me of this?
Reply
#5

I did, check it.
Reply
#6

Quote:
Originally Posted by FiReAlEx
Посмотреть сообщение
Try this:
pawn Код:
CMD:createhouse(playerid, params[])
{
    new string[128], Float:x, Float:y, Float:z, houseadr[128];
    GetPlayerPos(playerid, x, y, z);
    if(sscanf(params, "s[128]", houseadr)) return SendClientMessage(playerid, -1, ""Grey"Syntax"White": /createhouse [address].");
    for(new houseid=1; houseid<MAX_HOUSES; houseid++)
    {
        HouseInfo[houseid][hID] = houseid;
        format(HouseInfo[houseid][hAddress], 30, "%s", params);
        format(HouseInfo[houseid][hOwner], 32, "None");
        HouseInfo[houseid][hOwned] = 0;
        HouseInfo[houseid][hPickUp] = CreateDynamicPickup(1273, 1, x, y, z, 0);
        format(string, sizeof(string), ""Green"ID: %d\nHouse Address: %s", houseid, HouseInfo[houseid][hAddress]);
        HouseInfo[houseid][hText] = CreateDynamic3DTextLabel(string, -1, x, y, z, 20.0);
        houseid = MAX_HOUSES;
    }
    return 1;
}
Nope, you just changed the variable name.
Reply
#7

This is what park meant. You can't use params two times. Your code is like if(strcmp(params, params, true){ blablabla}. It's the samething. You should use another variable, like I did.
Reply
#8

Yeah I tried but it still doesn't seem to work :/
Reply
#9

i believe your code won't work as you always set it to the house id 1:

i have made this but i hope it can fit your code:

pawn Код:
CMD:createhouse(playerid, params[])
{
    new string[128], Float:x, Float:y, Float:z;
    GetPlayerPos(playerid, x, y, z);
    if(isnull(params)) return SendClientMessage(playerid, -1, ""Grey"Syntax"White": /createhouse [address]."); // checks if params was null so it gives the error
    for(new houseid=1; houseid<MAX_HOUSES; houseid++)
    {
        if(HouseInfo[houseid][hid] != 0) continue; // if the houseid wasnt 0 (if it was already existed) as the loop already starts with id 1, so it skips.
        HouseInfo[houseid][hID] = houseid; // i dont know how come that will work but ok.
        format(HouseInfo[houseid][hAddress], 30, "%s", params); // Sets the address
        format(HouseInfo[houseid][hOwner], 32, "None");
        HouseInfo[houseid][hOwned] = 0;
        HouseInfo[houseid][hPickUp] = CreateDynamicPickup(1273, 1, x, y, z, 0);
        format(string, sizeof(string), ""Green"ID: %d\nHouse Address: %s", houseid, HouseInfo[houseid][hAddress]);
        HouseInfo[houseid][hText] = CreateDynamic3DTextLabel(string, -1, x, y, z, 20.0);
        //houseid = MAX_HOUSES;  // break can be better than this
        break;
    }
    return 1;
}
Reply
#10

Quote:
Originally Posted by kirollos
Посмотреть сообщение
i believe your code won't work as you always set it to the house id 1:

i have made this but i hope it can fit your code:

pawn Код:
CMD:createhouse(playerid, params[])
{
    new string[128], Float:x, Float:y, Float:z;
    GetPlayerPos(playerid, x, y, z);
    if(isnull(params)) return SendClientMessage(playerid, -1, ""Grey"Syntax"White": /createhouse [address]."); // checks if params was null so it gives the error
    for(new houseid=1; houseid<MAX_HOUSES; houseid++)
    {
        if(HouseInfo[houseid][hid] != 0) continue; // if the houseid wasnt 0 (if it was already existed) as the loop already starts with id 1, so it skips.
        HouseInfo[houseid][hID] = houseid; // i dont know how come that will work but ok.
        format(HouseInfo[houseid][hAddress], 30, "%s", params); // Sets the address
        format(HouseInfo[houseid][hOwner], 32, "None");
        HouseInfo[houseid][hOwned] = 0;
        HouseInfo[houseid][hPickUp] = CreateDynamicPickup(1273, 1, x, y, z, 0);
        format(string, sizeof(string), ""Green"ID: %d\nHouse Address: %s", houseid, HouseInfo[houseid][hAddress]);
        HouseInfo[houseid][hText] = CreateDynamic3DTextLabel(string, -1, x, y, z, 20.0);
        //houseid = MAX_HOUSES;  // break can be better than this
        break;
    }
    return 1;
}
Thanks, I've tried this. It has fixed my ID bug where it only kept making houses as ID 1 but not my address issue.
Here is what happens when I type "/createhouse test"

Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)