AttachObjectToVehicle Problem
#1

If i buy a DFT-30,it have some object attached:
pawn Код:
else if(strcmp(x_nr,"DFT-30",true) == 0)
        {
            if(PlayerInfo[playerid][pLevel] < 3)
            {
                SendClientMessage(playerid, COLOR_DBLUE, "Ai nevoie de nivel 3 !");
                return 1;
            }
            if(GetPlayerMoney(playerid) < 50000)
            {
                SendClientMessage(playerid, COLOR_WHITE, "Nu ai destui bani");
                return 1;
            }
            new vehicleid = GetPlayerVehicleID(playerid);
            carid = CreateVehicle(578, 644.2462, -503.4926, 16.4790+0.2,359.1141,1,1,-1);
            side1[vehicleid] = CreateObject(983,0,0,-1000,0,0,0,100);
            side2[vehicleid] = CreateObject(983,0,0,-1000,0,0,0,100);
            CarInfo[carid][cModel] = 578;
            CarInfo[carid][cValue] = 50000;
            ModelMasina = "DFT-30";
            AttachObjectToVehicle(side1[vehicleid], carid, 1.275000,-1.500000,0.449999,0.000000,0.000000,0.000000);
            AttachObjectToVehicle(side2[vehicleid], carid, -1.350000,-1.500000,0.449999,0.000000,0.000000,0.000000);
            TotalMasini++
        }
But,if i restart the server,they are gone,i've tried:
pawn Код:
new side1[MAX_VEHICLES];
new side2[MAX_VEHICLES];
pawn Код:
public OnVehicleSpawn(vehicleid)
{
    if(IsADFT(vehicleid))
    {
        side1[vehicleid] = CreateObject(983,0,0,-1000,0,0,0,100);
        side2[vehicleid] = CreateObject(983,0,0,-1000,0,0,0,100);
        AttachObjectToVehicle(side1[vehicleid], vehicleid, 1.275000,-1.500000,0.449999,0.000000,0.000000,0.000000);
        AttachObjectToVehicle(side2[vehicleid], vehicleid, -1.350000,-1.500000,0.449999,0.000000,0.000000,0.000000);
    }
And it's not working,help me!
Reply
#2

Because it dosen't save on any .ini or something, its on the script itself. Restart = Resets everything which isn't saved in any .ini .txt or something in scriptfiles.
Reply
#3

IF i restart the server,and if i respawn the car,the objects appears
Reply
#4

Quote:
Originally Posted by calin1996
Посмотреть сообщение
IF i restart the server,and if i respawn the car,the objects appears
Then put a timer
OnGameModeInit
Like 3 Seconds then Respawn cars
Reply
#5

Thx,i've got it,but i have another problem:
I have a command which creates objects:
pawn Код:
if(strcmp(cmd, "/ramp", true) == 0)
    {
        if(IsPlayerConnected(playerid))
        {
            SetPlayerColor(playerid,COLOR_WHITE);
            new x_nr[256];
            x_nr = strtok(cmdtext, idx);
            if(!strlen(x_nr))
            {
                SendClientMessage(playerid, COLOR_WHITE, "UTILIZEAZA: /ramp (down sau up)");
                return 1;
            }
            {
                new rampup = GetPVarInt(playerid, "RampUp");
                new rampdn = GetPVarInt(playerid, "RampDown");
                new carid = GetPlayerVehicleID(playerid);
                //new mm = GetVehicleModel(carid);
                GetPlayerName(playerid, sendername, sizeof(sendername));
                if(IsADFT(carid))
                {
                    if(strcmp(x_nr,"up",true) == 0)
                    {
                        if(IsValidObject(rampdn))
                        {
                            DestroyObject(rampdn);
                            SetPVarInt(playerid, "RampDown", 0);
                        }
                        if(!IsValidObject(rampup))
                        {
                            rampup = CreateObject(18756,0,0,-1000,0,0,0,100);
                            SetPVarInt(playerid, "RampUp", rampup);
                        }
                        AttachObjectToVehicle(rampup, carid, 0.524999,-2.700001,1.650000,-269.999877,0.000000,89.099983);
                        format(string, sizeof(string), "* %s a ridicat rampa.", sendername);
                        ProxDetector(30.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
                        return 1;
                    }
                    else if(strcmp(x_nr,"down",true) == 0)
                    {
                        if(IsValidObject(rampup))
                        {
                            DestroyObject(rampup);
                            SetPVarInt(playerid, "RampUp", 0);
                        }
                        if(!IsValidObject(rampdn))
                        {
                            rampdn = CreateObject(18756,0,0,-1000,0,0,0,100);
                            SetPVarInt(playerid, "RampDown", rampdn);
                        }
                        AttachObjectToVehicle(rampdn, carid, 0.450000,-8.324991,0.075000,-35.100002,269.999877,178.199890);
                        format(string, sizeof(string), "* %s a lasat rampa.", sendername);
                        ProxDetector(30.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
                        return 1;
                    }
                }
            }
        }
    }
If i use /ramp up or /ramp down and relog,the object remains there and is not being destroyed,i've tried:
pawn Код:
public OnPlayerDisconnect(playerid, reason)
{
    new vehicleid = GetPlayerVehicleID(playerid);
    new rampup = GetPVarInt(playerid, "RampUp");
    new rampdn = GetPVarInt(playerid, "RampDown");
    if(IsADFT(vehicleid))
    {
    DestroyObject(rampup);
    DestroyObject(rampdn);
    }
But is not working,if i rejoin the object is still there
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)