SA-MP Forums Archive
House adding - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: House adding (/showthread.php?tid=346521)



House adding - iGetty - 28.05.2012

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;
}



Re: House adding - MP2 - 28.05.2012

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;


Re: House adding - iGetty - 28.05.2012

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


Re: House adding - MP2 - 28.05.2012

No. Just add static after the 'new'.