Pos saver help
#1

Hi i want this code to set the player pos to a the pos i picked when the player first starts the game. Heres my code

Quote:

#define FILTERSCRIPT

#include <a_samp>
#include <Dini>
#include <dudb>

new Floatositionx;
new Floatositiony;
new Floatositionz;

#if defined FILTERSCRIPT

public OnFilterScriptInit()
{
print("\n--------------------------------------");
print(" Position saver by Jueix");
print("--------------------------------------\n");
return 1;
}

public OnPlayerConnect(playerid)
{
LoadStats(playerid);
return 1;
}

public OnPlayerDisconnect(playerid, reason)
{
new Float;
new Float:y;
new Float:z;

GetPlayerPos(playerid,x,y,z);
positionx = x;
positiony = y;
positionz = z;
if (!dini_Exists(Pos(playerid)))
{
dini_Create(Pos(playerid));
}

SaveStats(playerid);
return 1;
}

public OnPlayerSpawn(playerid)
{
if(positionx[playerid] != 0 && positiony[playerid] !=0 && positionz[playerid] != 0); {
SetPlayerPos(playerid, 1676.8462, 1447.7908, 10.7833);
}
else {
SetPlayerPos(playerid,positionx,positiony,position z);
}
return 1;
}

Player(playerid)
{
new player[MAX_PLAYER_NAME];
GetPlayerName(playerid, player, sizeof(player));
return player;
}

Pos(playerid)
{
new a[256]; format(a, sizeof(a), "%s.ini",udb_encode(Player(playerid)));
return a;
}

SaveStats(playerid)
{
dini_IntSet(Pos(playerid), "PositionX", floatround(positionx));
dini_IntSet(Pos(playerid), "PositionY", floatround(positiony));
dini_IntSet(Pos(playerid), "PositionZ", floatround(positionz));
}

LoadStats(playerid)
{
positionx = dini_Int(Pos(playerid), "PositionX");
positiony = dini_Int(Pos(playerid), "PositionY");
positionz = dini_Int(Pos(playerid), "PositionZ");
}

public OnFilterScriptExit()
{
return 1;
}

#else

main()
{
print("\n----------------------------------");
print(" Blank Gamemode by Jueix");
print("----------------------------------\n");
}

#endif

i get errors saying that the positionx and that arnt defined in the if statement part off on playerspawn.
Reply
#2

You want to save automatic the players position when a player disconnect?
Reply
#3

https://sampwiki.blast.hk/wiki/SetSpawnInfo
Reply
#4

Quote:
Originally Posted by smokeweed
View Post
You want to save automatic the players position when a player disconnect?
no it saves on disconnect. I want it so if they don't have a save file it will load at the coordss i want the player to start at.
Reply
#5

pawn Code:
if(positionx[playerid] != 0 && positiony[playerid] !=0 && positionz[playerid] != 0); {
SetPlayerPos(playerid, 1676.8462, 1447.7908, 10.7833);
}
else {
SetPlayerPos(playerid,positionx,positiony,position z);
}
maybe switch != 0 into == 0..
you check if its not 0 then you spawn him at your default spawn.

AND you have to add
pawn Code:
positionx = dini_Int(Pos(playerid), "PositionX");
positiony = dini_Int(Pos(playerid), "PositionY");
positionz = dini_Int(Pos(playerid), "PositionZ");
at the spawn too.

so result :

pawn Code:
public OnPlayerSpawn(playerid)
{
        positionx = dini_Int(Pos(playerid), "PositionX");
        positiony = dini_Int(Pos(playerid), "PositionY");
        positionz = dini_Int(Pos(playerid), "PositionZ");
        if(positionx[playerid] != 0 && positiony[playerid] !=0 && positionz[playerid] != 0);
        {
                SetPlayerPos(playerid,positionx,positiony,position z);
        }
        else
        {
                SetPlayerPos(playerid, 1676.8462, 1447.7908, 10.7833);
        }
        return 1;
}
Reply
#6

Quote:
Originally Posted by CmZxC
View Post
pawn Code:
if(positionx[playerid] != 0 && positiony[playerid] !=0 && positionz[playerid] != 0); {
SetPlayerPos(playerid, 1676.8462, 1447.7908, 10.7833);
}
else {
SetPlayerPos(playerid,positionx,positiony,position z);
}
maybe switch != 0 into == 0..
you check if its not 0 then you spawn him at your default spawn.

AND you have to add
pawn Code:
positionx = dini_Int(Pos(playerid), "PositionX");
positiony = dini_Int(Pos(playerid), "PositionY");
positionz = dini_Int(Pos(playerid), "PositionZ");
at the spawn too.

so result :

pawn Code:
public OnPlayerSpawn(playerid)
{
        positionx = dini_Int(Pos(playerid), "PositionX");
        positiony = dini_Int(Pos(playerid), "PositionY");
        positionz = dini_Int(Pos(playerid), "PositionZ");
        if(positionx[playerid] != 0 && positiony[playerid] !=0 && positionz[playerid] != 0);
        {
                SetPlayerPos(playerid,positionx,positiony,position z);
        }
        else
        {
                SetPlayerPos(playerid, 1676.8462, 1447.7908, 10.7833);
        }
        return 1;
}
C:\Users\Desktop\New folder\pawno\pos.pwn(51) : error 028: invalid subscript (not an array or too many subscripts): "positionx"
C:\Users\Desktop\New folder\pawno\pos.pwn(51) : warning 215: expression has no effect
C:\Users\Desktop\New folder\pawno\pos.pwn(51) : error 001: expected token: ";", but found "]"
C:\Users\Desktop\New folder\pawno\pos.pwn(51) : error 029: invalid expression, assumed zero
C:\Users\Desktop\New folder\pawno\pos.pwn(51) : fatal error 107: too many error messages on one line
its giving me these errors
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)