Help with /enter.
#1

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;
}
Reply
#2

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;
}
Reply
#3

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

Reply
#4

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

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
Reply
#6

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

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



Could you explain why this happens?
Reply
#8

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

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


Forum Jump:


Users browsing this thread: 1 Guest(s)