Saving/loading vehpos
#1

I have a command to save (/sloc) and load (/lloc) player position, i tried to save the current vehicle position when using /sloc and spawning the vehicle back with /lloc, but i get an error. Here are the 2 cmds:

pawn Код:
CMD:sloc(playerid, params[])
{
    if(pInfo[playerid][Logged] == 0) return SCM(playerid,0x0080C0FF,"Please login before using this command.");
    if(pInfo[playerid][Admin] >= 3)
    {
    if(Saved[playerid] == 0)
    {
    Saved[playerid] = 1;
    }
    new Float:xpoz,Float:ypoz,Float:zpoz;
    GetPlayerPos(playerid,xpoz,ypoz,zpoz);
    new currentveh;
    currentveh = GetPlayerVehicleID(playerid);
    new Float:vxpoz,Float:vypoz,Float:vzpoz;
    GetVehiclePos(currentveh,vxpoz,vypoz,vzpoz);
    new aName[24];
    GetPlayerName(playerid,aName,128);
    SetPVarFloat(playerid,"XPos",xpoz); SetPVarFloat(playerid,"YPos",ypoz); SetPVarFloat(playerid,"ZPos",zpoz);
    SetPVarFloat(playerid,"VXPos",vxpoz); SetPVarFloat(playerid,"VYPos",vypoz); SetPVarFloat(playerid,"VZPos",vzpoz);
    SCM(playerid, pink, "You have saved your position, now type /lloc to go back there.");
    new msg[170];
    format(msg, sizeof(msg), "0,4** Admin %s (%d) has saved his coordinates: %f,%f,%f - using /sloc.", aName,playerid,xpoz,ypoz,zpoz);
    IRC_GroupSay(gGroupID, IRC_ACHANNEL, msg);
    IRC_GroupSay(gGroupID, IRC_CHANNEL, msg);
    }
    return 1;
}

CMD:lloc(playerid, params[])
{
    if(pInfo[playerid][Logged] == 0) return SCM(playerid,0x0080C0FF,"Please login before using this command.");
    if(pInfo[playerid][Admin] >= 3)
    {
    if(Saved[playerid] == 1)
    {
    new aName[24];
    GetPlayerName(playerid,aName,128);
    SetPlayerPosEx(playerid, GetPVarFloat(playerid,"XPos"), GetPVarFloat(playerid,"YPos"), GetPVarFloat(playerid,"ZPos"));
    SetVehiclePos(currentveh, GetPVarFloat(playerid,"VXPos"), GetPVarFloat(playerid,"VYPos"), GetPVarFloat(playerid,"VZPos"));
    SCM(playerid, pink, "You have teleported to your last saved position.");
    }
    else SCM(playerid, pink, "You didn't save your position! Please type /sloc again.");
    }
    return true;
}
(6645) : error 017: undefined symbol "currentveh"

Line 6645:

pawn Код:
SetVehiclePos(currentveh, GetPVarFloat(playerid,"VXPos"), GetPVarFloat(playerid,"VYPos"), GetPVarFloat(playerid,"VZPos"));
Thanks.
Reply
#2

You don't have this:
PHP код:
new currentveh;
public 
OnGameModeInit()
{
        
currentveh CreateVehicle(idxyza, -1, -1100);
        return 
1;

Reply
#3

Quote:
Originally Posted by radiobizza
Посмотреть сообщение
You don't have this:
PHP код:
new currentveh;
public 
OnGameModeInit()
{
        
currentveh CreateVehicle(idxyza, -1, -1100);
        return 
1;

I think i don't need it since im not creating a new vehicle but SAVING and LOADING (temporary) the current player's one.
Reply
#4

You tried?
Reply
#5

Yes.
Reply
#6

pawn Код:
SetPVarInt(playerid,"CurVeh",currentveh);
and load

pawn Код:
GetPVarInt(playerid,"CurVeh");
Reply
#7

Seems it saves the old vehicle position but doesn't respawn the vehicle when using /lloc. I wanna save the WHOLE vehicle (the id) and not only the position.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)