/save /load script please, i need help
#1

Ive been trying for hours to get a /save /load postion script working. It loads the players postion fine but if your in a car, it only teles the player and not the car. Please help!
Reply
#2

pawn Код:
new Float:pSavedPos[MAX_PLAYERS][4];
new bool:HasPlayerSavedPos[MAX_PLAYERS];
pawn Код:
if(strcmp(cmdtext, "/save", true, 5) == 0)
{
    new Float:X, Float:Y, Float:Z, Float:Ang;

    if(IsPlayerInAnyVehicle(playerid))
    {
        new VehID = GetPlayerVehicleID(playerid);
        GetVehiclePos(VehID, X, Y, Z);
        GetVehicleZAngle(VehID, Ang);
    }

    else
    {
        GetPlayerPos(playerid, X, Y, Z);
        GetPlayerFacingAngle(playerid, Ang);
    }
   
    pSavedPos[playerid][0] = X;
    pSavedPos[playerid][1] = Y;
    pSavedPos[playerid][2] = Z;
    pSavedPos[playerid][3] = Ang;

    HasPlayerSavedPos[playerid] = true;

    SendClientMessage(playerid, 0xdf0f00ff, "* Your position has been successfully saved!");
   
    return 1;
}
pawn Код:
if(strcmp(cmdtext, "/load", true, 5) == 0)
{
    if(!HasPlayerSavedPos[playerid])
        return SendClientMessage(playerid, 0xdf0f00ff, "* You didn't save any position yet!");

    if(IsPlayerInAnyVehicle(playerid))
    {
        new VehID = GetPlayerVehicleID(playerid);
        SetVehiclePos(VehID, pSavedPos[playerid][0], pSavedPos[playerid][1], pSavedPos[playerid][2]);
        SetVehicleZAngle(VehID, pSavedPos[playerid][3]);
        PutPlayerInVehicle(playerid, VehID, 0);

        SendClientMessage(playerid, 0xdf0f00ff, "* You and your vehicle have been successfully teleported to the saved position!");
    }

    else
    {
        SetPlayerPos(playerid, pSavedPos[playerid][0], pSavedPos[playerid][1], pSavedPos[playerid][2]);
        SetPlayerFacingAngle(playerid, pSavedPos[playerid][3]);

        SendClientMessage(playerid, 0xdf0f00ff, "* You've been successfully teleported to the saved position!");
    }
   
    return 1;
}
It should work, let me know
Reply
#3

Quote:
Originally Posted by Kase
Посмотреть сообщение
-code-
It should work, let me know
You forgot the vehicle position saving.
Reply
#4

I save the position and when i load it it says i never saved a positon
Reply
#5

Quote:
Originally Posted by [FU]Victious
Посмотреть сообщение
You forgot the vehicle position saving.
Yeah, you're right. Now it should be good

Quote:
Originally Posted by Hippotipus
Посмотреть сообщение
I save the position and when i load it it says i never saved a positon
Really strange, I couldn't find any error in my script

Try with the edited code I just posted, it may work.
Reply
#6

Quote:
Originally Posted by Hippotipus
Посмотреть сообщение
I save the position and when i load it it says i never saved a positon
You cannot use /save because it's already in use by SA:MP.
Reply
#7

Aww yeah, I didn't think about that! Hippotipus, I guess you can simply modify the commands' names, it will surely work
Reply
#8

yea did that so i could test it, ill try ur edited one :P
Reply
#9

still says position not saved o.O
Reply
#10

Debug it?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)