[HELP] Delete old on spawn new.
#1

I have made a car spawn script and made this:
pawn Код:
if (strcmp(cmd, "/spawncar", true) ==0 )
    {
    if (PlayerInfo[playerid][pCar] != 0)
        {
        if (PlayerInfo[playerid][pCar] == 496)
        {
        /*new Float: X, Float: Y, Float: Z, Float: Ang, Name[30];
            GetPlayerPos(playerid, X, Y, Z);
            GetPlayerFacingAngle(playerid, Ang);
            GetPlayerName(playerid, Name, sizeof( Name ));
            PVeh[playerid] = CreateVehicle(522, X, Y , Z, Ang, 75,3, 5000000);
            PutPlayerInVehicle(playerid, PVeh[playerid], 0);
            LinkVehicleToInterior(PVeh[playerid], GetPlayerInterior(playerid));
            printf("personal nrg created for %s.", Name);
            SendClientMessage(playerid,0x0066FFAA, "personal nrg created.");
            SetVehicleParamsForPlayer(PVeh[playerid], playerid, 0, 0);
            for(new i=0; i <= MAX_PLAYERS; i++)
            {
                if ( IsPlayerConnected(i) )
                {
                    if ( i != playerid )
                    {
                        SetVehicleParamsForPlayer(PVeh[playerid], i, 0, 1);
                    }
                }
            }*/

            SetTimer("Destroyaaa",1,0);
        new Float: X, Float: Y, Float: Z, Float: Ang, Name[30];
        GetPlayerPos(playerid, X, Y, Z);
        GetPlayerFacingAngle(playerid, Ang);
        GetPlayerName(playerid, Name, sizeof( Name ));
        aaa[playerid]=CreateStreamVehicle(496,X ,Y ,Z, Ang,colori,colorii,-1);
        PutPlayerInStreamVehicle(playerid,aaa[playerid], 0);
        colori = PlayerInfo[playerid][pColi];
        colorii = PlayerInfo[playerid][pColii];
        new car = GetPlayerStreamVehicleID(playerid);
        ChangeStreamVehicleColor(car, colori, colorii);// HIER MOET JE ZIJN !!!
        SetStreamVehicleParamsForPlayer(aaa[playerid], playerid, 0, 0);
        aaa[playerid] = 1;
        for(new i=0; i <= MAX_PLAYERS; i++)
        if ( i != playerid )
                    {
                        SetStreamVehicleParamsForPlayer(aaa[playerid], i, 0, 1);
                    }
        return 1;..................................
        }
It has some more cars in it but thats not important, the important thing is, of i spawn a car it deletes it right away )except for the first car is pawn) now i know this is because of the timer, but that timer has to make sure if i spawn a new car the old one i spawned disapears, but this doesn't happen either + only one player can spawn the car, the deleting the old car deletes every old spawned car (so from other players too), now my question, how could i realise what i need so it deletes the old, and only the old one of me not everybody, when i spawn a new?
Reply
#2

You're a very sloppy scripter. It's best to name your variables something that is related to what it's representing or trying to do.
Reply
#3

Quote:
Originally Posted by NiiRV4N4
You're a very sloppy scripter. It's best to name your variables something that is related to what it's representing or trying to do.
What do you mean? can you explain??
Reply
#4

Quote:
Originally Posted by WThieves
Quote:
Originally Posted by NiiRV4N4
You're a very sloppy scripter. It's best to name your variables something that is related to what it's representing or trying to do.
What do you mean? can you explain??
I don't know how you manage to not forget what "aaa" means.
Reply
#5

Quote:
Originally Posted by NiiRV4N4
Quote:
Originally Posted by WThieves
Quote:
Originally Posted by NiiRV4N4
You're a very sloppy scripter. It's best to name your variables something that is related to what it's representing or trying to do.
What do you mean? can you explain??
I don't know how you manage to not forget what "aaa" means.
I just don't, I keep everything thats needed in my textfiles, and thats how i do it, but i still don't know how to solve the problem!
Reply
#6

DUDE

do you want if u exit the spawned vehicle it destroys?
Reply
#7

Quote:
Originally Posted by Kar
DUDE

do you want if u exit the spawned vehicle it destroys?
No not completely, i want if i use the command to spawn a vehicle again it destroys the old one and spawns a new one,
And i need it so that anybody can have their own one car, so if i spawn a new one, someone elses doesn't get deleted.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)