/createhouse <address> not working -
AphexCCFC - 12.09.2013
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;
}
Re: /createhouse <address> not working -
park4bmx - 12.09.2013
U need to hold the "Params" into something else.
E.g new variable
Re: /createhouse <address> not working -
FiReAlEx - 12.09.2013
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;
}
Re: /createhouse <address> not working -
AphexCCFC - 12.09.2013
Is there a little example you could give me of this?
Re: /createhouse <address> not working -
FiReAlEx - 12.09.2013
I did, check it.
Re: /createhouse <address> not working -
AphexCCFC - 12.09.2013
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.
Re: /createhouse <address> not working -
FiReAlEx - 12.09.2013
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.
Re: /createhouse <address> not working -
AphexCCFC - 12.09.2013
Yeah I tried but it still doesn't seem to work :/
Re: /createhouse <address> not working -
Kirollos - 12.09.2013
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;
}
Re: /createhouse <address> not working -
AphexCCFC - 12.09.2013
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"