[HELP] Car repawn
#1

I have made a FS with transforming cars (i made it with help of looking into the existing transformer FS) and it works, but when i transform the car into another one it respawns at the last place it transformed but i don't want that i want it to respawn at the normal spawn place Here is the FS:
pawn Код:
#include <a_samp>
new transformer2;

public OnFilterScriptInit()
{
    print("Transformer filterscript by [RTA]Dave"); //DO NOT remove these credits!
    transformer2 = AddStaticVehicleEx(411,-2209.5,2398.5,4.6,0,0,0,120);
       LinkVehicleToInterior(transformer2,1);
    cloaked = 1;
    return 1;
}

public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
    new Float:info[7],model;
if (IsPlayerInVehicle(playerid,transformer2))
    {
        if (newkeys & KEY_ANALOG_LEFT)
        {
            GetVehicleVelocity(transformer2,info[4],info[5],info[6]);
            GetVehiclePos(transformer2,info[0],info[1],info[2]);
            GetVehicleZAngle(transformer2,info[3]);
            GetVehicleModel(model);
            DestroyVehicle(transformer2);
            transformer2 = AddStaticVehicle(452,info[0],info[1],info[2],info[3],0,0);
            PutPlayerInVehicle(playerid,transformer2,0);
            PlayerPlaySound(playerid,1133,0,0,0);
            SetVehicleVelocity(transformer2,info[4],info[5],info[6]);
        }
        if (newkeys & KEY_ANALOG_RIGHT)
        {
            GetVehicleVelocity(transformer2,info[4],info[5],info[6]);
            GetVehiclePos(transformer2,info[0],info[1],info[2]);
            GetVehicleZAngle(transformer2,info[3]);
            GetVehicleModel(model);
            DestroyVehicle(transformer2);
            transformer2 = AddStaticVehicle(519,info[0],info[1],info[2],info[3],0,0);
            PutPlayerInVehicle(playerid,transformer2,0);
            PlayerPlaySound(playerid,1133,0,0,0);
            SetVehicleVelocity(transformer2,info[4],info[5],info[6]);
        }
        if (newkeys & KEY_ANALOG_DOWN)
        {
            GetVehicleVelocity(transformer2,info[4],info[5],info[6]);
            GetVehiclePos(transformer2,info[0],info[1],info[2]);
            GetVehicleZAngle(transformer2,info[3]);
            GetVehicleModel(model);
            DestroyVehicle(transformer2);
            transformer2 = AddStaticVehicle(411,info[0],info[1],info[2],info[3],0,0);
            PutPlayerInVehicle(playerid,transformer2,0);
            PlayerPlaySound(playerid,1133,0,0,0);
            SetVehicleVelocity(transformer2,info[4],info[5],info[6]);
        }
        if (newkeys & KEY_ANALOG_UP)
        {
            GetVehicleVelocity(transformer2,info[4],info[5],info[6]);
            GetVehiclePos(transformer2,info[0],info[1],info[2]);
            GetVehicleZAngle(transformer2,info[3]);
            GetVehicleModel(model);
            DestroyVehicle(transformer2);
            transformer2 = AddStaticVehicle(522,info[0],info[1],info[2],info[3],0,0);
            PutPlayerInVehicle(playerid,transformer2,0);
            PlayerPlaySound(playerid,1133,0,0,0);
            SetVehicleVelocity(transformer2,info[4],info[5],info[6]);
        }
        if (newkeys & KEY_SUBMISSION)
        {
            if(cloaked == 1)
            {
                LinkVehicleToInterior(transformer2,0);
                cloaked = 0;
                return 1;
            }
        }
    }
return 1;
}
Reply
#2

If this is supposed to be the normal spawnplace,

X,Y,Z,ANGLE = -2209.5,2398.5,4.6,0

Then don't get the coцrdinates from the previous vehicle but put those in stead.

wrong:
pawn Код:
GetVehiclePos(transformer2,info[0],info[1],info[2]);
transformer2 = AddStaticVehicle(452,info[0],info[1],info[2],info[3],0,0);
pawn Код:
transformer2 = AddStaticVehicle(452,-2209.5,2398.5,4.6,0,0,0);
Riz
Reply
#3

Quote:
Originally Posted by Rizard
If this is supposed to be the normal spawnplace,

X,Y,Z,ANGLE = -2209.5,2398.5,4.6,0

Then don't get the coцrdinates from the previous vehicle but put those in stead.

wrong:
pawn Код:
GetVehiclePos(transformer2,info[0],info[1],info[2]);
transformer2 = AddStaticVehicle(452,info[0],info[1],info[2],info[3],0,0);
pawn Код:
transformer2 = AddStaticVehicle(452,-2209.5,2398.5,4.6,0,0,0);
Riz
This will make you spawn back at the place you toke it, but it has to make you spawn at the place you push the button (duhh)
Reply
#4

You could be a bit nicer to the only person who tries to understand your english

so it wasn't the normal spawn place you meant...

Quote:
Originally Posted by Don Correlli
You can't detect keys UP, DOWN, LEFT or RIGHT at OnPlayerKeyStateChange callback, use GetPlayerKeys with the timer.
Reply
#5

Quote:
Originally Posted by Rizard
You could be a bit nicer to the only person who tries to understand your english

so it wasn't the normal spawn place you meant...

Quote:
Originally Posted by Don Correlli
You can't detect keys UP, DOWN, LEFT or RIGHT at OnPlayerKeyStateChange callback, use GetPlayerKeys with the timer.
I'm sorry then, but what do you want to say with that quote??
Reply
#6

Asuming what he says is true,

You should be using a timer that checks what keys are pressed every ... milliseconds. (in stead of what you are doing atm)

Using GetPlayerKeys...

for example

pawn Код:
public CheckKeys(playerid)
{
  if(GetPlayerKeys(playerid)==...)
  {
    ....
  }
}

OnPlayerEnterVehicle()
{
  if(vehicleid==...)
  {
   SetTimer("CheckKeys", 200, 1);
  }
}
More info about the GetPlayerKeys.... here https://sampwiki.blast.hk/wiki/GetPlayerKeys
Reply
#7

Quote:
Originally Posted by Rizard
Asuming what he says is true,

You should be using a timer that checks what keys are pressed every ... milliseconds. (in stead of what you are doing atm)

Using GetPlayerKeys...

for example

pawn Код:
public CheckKeys(playerid)
{
  if(GetPlayerKeys(playerid)==...)
  {
    ....
  }
}

OnPlayerEnterVehicle()
{
 if(vehicleid==...)
 {
   SetTimer("CheckKeys", 200, 1);
 }
}
More info about the GetPlayerKeys.... here https://sampwiki.blast.hk/wiki/GetPlayerKeys
I don't really get you , did you read my question i want them to respawn at the starting place, and you are trying to explain me how to make it work.
And the funniest is they allready work!!! only the spawn place doesn't work correctly because it changes after transforming,
But just so that you know the keys DO work this way!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)