Pickup doesnt create. -
TheINCDope - 06.11.2014
Hello, Ive created a script where it loads houses from db. so hares the part of the script that doesnt work.
Код:
stock LoadHouses()
{
new
Str[255],
hID,
Float:intX,
Float:intY,
Float:intZ,
Float:exitX,
Float:exitY,
Float:exitZ,
hOwner[24],
hWorld,
hPrice,
hIntID,
hLocked;
mysql_query("SELECT * FROM `houses`");
mysql_store_result();
new haI = 1;
if(mysql_num_rows() > 0)
{
while(mysql_fetch_row(Str))
{
sscanf(Str, "p<|>is[128]s[24]ffffffiiii", hID, intX, intY, intZ, exitX, exitY, exitZ, hOwner, hWorld, hPrice, hIntID, hLocked);
HousePickup[hID] = CreatePickup(1273, 1, exitX, exitY, exitZ, 0);
iHos[haI][haID] = haI;
iHos[haI][haExitX] = exitX;
iHos[haI][haExitY] = exitY;
iHos[haI][haExitZ] = exitZ;
iHos[haI][haIntX] = intX;
iHos[haI][haIntY] = intY;
iHos[haI][haIntZ] = intZ;
iHos[haI][haIntID] = hIntID;
iHos[haI][haPrice] = hPrice;
iHos[haI][haLocked] = hLocked;
iHos[haI][haWorld] = hWorld;
format(iHos[haI][haOwner], 24, "%s", hOwner);
haI++;
hTotal++;
}
}
mysql_free_result();
printf("** %i\t<->\tHouses Loaded from\t<->\tMySQL\t\t **", hTotal);
return 1;
}
So, it doesnt load the pickup, why is that i wonder, I think its eather the pickup doesnt create cuz of wrong command, or cuz of something wrong getting the mysql data, tables are correct. any ideas?
Re: Pickup doesnt create. -
CNMike - 06.11.2014
It could be because you are setting it specific to virtual world 0 change it to -1, so it appears in all worlds.
CreatePickup(1273, 1, exitX, exitY, exitZ, -1);
It can also be because your not loading the right coordinates into the pickup
Re: Pickup doesnt create. -
TheINCDope - 06.11.2014
Quote:
Originally Posted by CNMike
It could be because you are setting it specific to virtual world 0 change it to -1, so it appears in all worlds.
CreatePickup(1273, 1, exitX, exitY, exitZ, -1);
It can also be because your not loading the right coordinates into the pickup
|
Thanks, but it didint work out, so that means it doesnt load the right cordinates right? Is there an easy way to see what cords is it getting? Or do i need to create command that would show the cords?
Re: Pickup doesnt create. -
CNMike - 06.11.2014
just print the coords to the console
new FormatBuffer[255];
format(FormatBuffer,sizeof(FormatBuffer),"X: %f Y:%f Z:%f",exitX,exitY,exitZ);
print(FormatBuffer);
Re: Pickup doesnt create. -
CNMike - 06.11.2014
The Below code is wrong, so your loading the numbers wrong.
Код:
sscanf(Str, "p<|>is[128]s[24]ffffffiiii", hID, intX, intY, intZ, exitX, exitY, exitZ, hOwner, hWorld, hPrice, hIntID, hLocked);
hID <- INT
intX <- Float
intY <- Float
intZ <- Float
exitX <- Float
exitY <- Float
exitZ <- Float
hOwner <- String
hWorld <- INT
hPrice <- INT
hIntID <- INT
hLocked <- INT
=
Код:
sscanf(Str, "p<|>iffffffs[24]iiii", hID, intX, intY, intZ, exitX, exitY, exitZ, hOwner, hWorld, hPrice, hIntID, hLocked);
Re: Pickup doesnt create. -
TheINCDope - 06.11.2014
Thx man, it works, so let me understand this.
i means that its INT and get numbers only, then float its verchar so it stands for f, and then s is for string, and then 4 int again right?
so like you said and 24 is a string thats why its a s[24]?
Thanks man alot clearler now, since I created this script, but I diddint understand that part.
Re: Pickup doesnt create. -
CNMike - 06.11.2014
No problem, I know how frustrating scripting can be sometimes. Check this out
https://github.com/Y-Less/sscanf/wiki. It has alot of information on how it works. Also the p<|> is simply defining "|" as the character the separates your data.
Re: Pickup doesnt create. -
TheINCDope - 06.11.2014
Quote:
Originally Posted by CNMike
No problem, I know how frustrating scripting can be sometimes. Check this out https://github.com/Y-Less/sscanf/wiki. It has alot of information on how it works. Also the p<|> is simply defining "|" as the character the separates your data.
|
Oh, was wondering about that, and ye, it is frustrating but no pain no gain, you know. Thanks again man. Lifesaver, I was hoping Ill finish the pickup thingy today. The rest is easy, I think.. LOL
![Cheesy](images/smilies/biggrin.png)
Ty again! Rep for ya btw.
![Smiley](images/smilies/smile.png)
If Ill figure out how to give it haha