SA-MP Forums Archive
Help with /enter. - 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: Help with /enter. (/showthread.php?tid=283404)



Help with /enter. - Dokins - 14.09.2011

Hello, I know ive posted a few times already, but the only way to learn is through experience. Heres the issue.

When I /enter, it doesnt retrieve the data from the MYSQL base, therefor I cannot /enter. the Data retrieval and command are as follows:

pawn Код:
new factionid = MySQL_GetValue(FactionSQLID[factionid],"id" "factions");
        FactionIntX[factionid] = MySQL_GetValue(FactionSQLID[factionid],"FactionIntX" "factions");
        FactionIntY[factionid] = MySQL_GetValue(FactionSQLID[factionid],"FactionIntY" "factions");
        FactionIntZ[factionid] = MySQL_GetValue(FactionSQLID[factionid],"FactionIntZ" "factions");
        FactionInt[factionid] = MySQL_GetValue(FactionSQLID[factionid],"FactionInt" "factions");
        FactionEntX[factionid] = MySQL_GetValue(FactionSQLID[factionid],"FactionEntX" "factions");
        FactionEntY[factionid] = MySQL_GetValue(FactionSQLID[factionid],"FactionEntY" "factions");
        FactionEntZ[factionid] = MySQL_GetValue(FactionSQLID[factionid],"FactionEntZ" "factions");
Actual /enter.

pawn Код:
CMD:enter(playerid, params[])
{
    if(IsPlayerInRangeOfPoint(playerid, 5.0, FactionEntX[factionid], FactionEntY[factionid],FactionEntZ[factionid]))
    {
        SetPlayerPos(playerid, FactionIntX[factionid],FactionIntY[factionid],FactionIntZ[factionid]);
        SetPlayerInterior(playerid, FactionInt[factionid]);
        SetPlayerVirtualWorld(playerid, 0);
        }
    return 1;
 }

CMD:exit(playerid, params[])
{
    if(IsPlayerInRangeOfPoint(playerid, 5.0, FactionIntX[factionid],FactionIntY[factionid],FactionIntZ[factionid]))
    {
        SetPlayerPos(playerid, FactionEntX[factionid],FactionEntY[factionid],FactionEntZ[factionid]);
        SetPlayerVirtualWorld(playerid, 0);
        }
    return 1;
}



Re: Help with /enter. - scottyishere - 14.09.2011

Well I don't think factionid is a global variable. From what you are showing me here factionid is undefined in the CMDs. I don't really know the structure of your gamemode but I'm sure you need to add something like this:

pawn Код:
CMD:enter(playerid, params[])
{
   for(new factionid=0;factionid<MAX_FACTIONS;factionid++)
   {
       if(IsPlayerInRangeOfPoint(playerid, 5.0, FactionEntX[factionid], FactionEntY[factionid],FactionEntZ[factionid]))
       {
            SetPlayerPos(playerid, FactionIntX[factionid],FactionIntY[factionid],FactionIntZ[factionid]);
            SetPlayerInterior(playerid, FactionInt[factionid]);
            SetPlayerVirtualWorld(playerid, 0);
       }
   }
   return 1;
}

CMD:exit(playerid, params[])
{
   for(new factionid=0;factionid<MAX_FACTIONS;factionid++)
   {
        if(IsPlayerInRangeOfPoint(playerid, 5.0, FactionIntX[factionid],FactionIntY[factionid],FactionIntZ[factionid]))
        {
              SetPlayerPos(playerid, FactionEntX[factionid],FactionEntY[factionid],FactionEntZ[factionid]);
              SetPlayerVirtualWorld(playerid, 0);
              SetPlayerInterior(playerid,0);
        }
   }
   return 1;
}



Re: Help with /enter. - rt-2 - 14.09.2011

when you call this line:
Quote:

if(IsPlayerInRangeOfPoint(playerid, 5.0, FactionIntX[factionid],FactionIntY[factionid],FactionIntZ[factionid]))

factionid is not define

Use:
Quote:

new i = 0;
while(i<sizeof(FactionInt)
{
if(IsPlayerInRangeOfPoint(playerid, 5.0, FactionEntX[i], FactionEntY[i],FactionEntZ[i]))
{
SetPlayerPos(playerid, FactionIntX[i],FactionIntY[i],FactionIntZ[i]);
SetPlayerInterior(playerid, FactionInt[i]);
SetPlayerVirtualWorld(playerid, 0);
}
i++;
}




Re: Help with /enter. - Dokins - 14.09.2011

That works, thanks! but, there is an issue and thats when I type /exit the uh FactionEnt is like below the map? :S


Re: Help with /enter. - scottyishere - 14.09.2011

Hmm, that's weird.. it may be the way you saved the coords. Try adding +1 to the Z coordinate maybe that helps if you say 'it's under the map'.
pawn Код:
FactionEntZ[factionid]+1



Re: Help with /enter. - Dokins - 14.09.2011

It seems to be very weird, i'll send you a screenshot if this doesnt work, thanks!


Re: Help with /enter. - Dokins - 14.09.2011

Alright heres a screenshot, its not exactly below, but its almost a different world:



Could you explain why this happens?


Re: Help with /enter. - scottyishere - 14.09.2011

Yes you forgot to change the interior back to 0 when you exit the building.
pawn Код:
SetPlayerInterior(playerid,0);
Add that next to SetPlayerVirtualWorld.


Re: Help with /enter. - Dokins - 14.09.2011

Much appreciated!! + rep for fast answers and communication.