House adding
#1

When I do this, is saves the floats as 0.000000 for all of them.

When I do the SetPlayerPos it sets me to Blueberry falling underneath the ground.

What's up with it?

pawn Код:
command(addhouse, playerid, params[])
{
    new Float:IntX, Float:IntY, Float:IntZ, Float:ExtX, Float:ExtY, Float:ExtZ, Interior, string[256], Section[9];
    if(Player[playerid][AdminLevel] >= 10 || IsPlayerAdmin(playerid))
    {
        if(sscanf(params, "s[9]", Section)) return SendClientMessage(playerid, WHITE, "Server: /addhouse [exterior/interior/complete]");
        {
            if(strmatch("interior", Section))
            {
                GetPlayerPos(playerid, IntX, IntY, IntZ);
                Interior = GetPlayerInterior(playerid);
                format(string, sizeof(string), "Interior set. (%f %f %f - %d)", IntX, IntY, IntZ, Interior);
                SendClientMessage(playerid, WHITE, string);
            }
            else if(strmatch("exterior", Section))
            {
                GetPlayerPos(playerid, ExtX, ExtY, ExtZ);
                format(string, sizeof(string), "Exterior set. (%f %f %f)", ExtX, ExtY, ExtZ);
                SendClientMessage(playerid, WHITE, string);
            }
            else if(strmatch("complete", Section))
            {
                format(string, sizeof(string), "House added.");
                printf("%f, %f, %f, %f, %f, %f, %i", ExtX, ExtY, ExtZ, IntX, IntY, IntZ, Interior);
                SendClientMessage(playerid, WHITE, string);
                SetPlayerPos(playerid, ExtX, ExtY, ExtZ);
                SetPlayerInterior(playerid, 0);
                SaveHouse(ExtX, ExtY, ExtZ, IntX, IntY, IntZ, Interior);
            }
            else return SendClientMessage(playerid, WHITE, "Server: /addhouse [exterior/interior/complete]");
        }
    }
    else return SendClientMessage(playerid, GREY, AdminOnly);
    return 1;
}
Reply
#2

Because the variables are 'local' in scope. When you type it again, the variables are reset (re-initialized). I believe you can use static, i.e. new static Float:IntX;
Reply
#3

So, should I define them at the top of my script?
Reply
#4

No. Just add static after the 'new'.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)