Get xyz of house pos?
#1

Hi all
I have a small problem

I want to make a function witch i can get the position (XYZ) of my house, but it doesn't work, i tried almost everything but... doesn't work, what to do?

pawn Код:
stock GetHouseEnterXYZ(houseid)
{
    new gtx[128];
    format(gtx, sizeof(gtx), "%f%f%f", HouseInfo[houseid][hEnterX], HouseInfo[houseid][hEnterY], HouseInfo[houseid][hEnterZ]);
    return strval(gtx);
}
//test command
YCMD:hprice(playerid, params[], help)
{
    #pragma unused help
    new houseid1, dure[128];
    if(sscanf(params, "i", houseid1)) return SendClientMessage(playerid, -1, "Usage: /hprice [House ID]");
    format(dure, sizeof(dure), "Coordiantes of house ID %d is %d", houseid1, GetHouseEnterXYZ(houseid1));
    SendClientMessage(playerid, COLOR_ORANGE, dure);
    return 1;
}
Reply
#2

What the hell are you doing? Why'd you do strval for a string with floats?
pawn Код:
stock GetHouseEnterXYZ(houseid)
{
    new gtx[128];
    format(gtx, sizeof(gtx), "%f %f %f", HouseInfo[houseid][hEnterX], HouseInfo[houseid][hEnterY], HouseInfo[houseid][hEnterZ]);
    return gtx;
}
//test command
YCMD:hprice(playerid, params[], help)
{
    #pragma unused help
    new houseid1, dure[128];
    if(sscanf(params, "i", houseid1)) return SendClientMessage(playerid, -1, "Usage: /hprice [House ID]");
    format(dure, sizeof(dure), "Coordiantes of house ID %d is %s", houseid1, GetHouseEnterXYZ(houseid1));
    SendClientMessage(playerid, COLOR_ORANGE, dure);
    return 1;
}
Reply
#3

%d = number
%i = integer
%s = string (Text or text AND numbers)
%f = float (x,y,z)

You can't type floats with %d.
And you can't return strval(*); to return a string.

strval is a function that converts a string to an integer.

https://sampwiki.blast.hk/wiki/strval
https://sampwiki.blast.hk/wiki/Category:..._Documentation
Reply
#4

guys thanks a lot, specialy wups, I've never know how to use something like this but now I know Thanks a lot again, rep+ all
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)