HELP | The car spawned will destroy!
#1

Hello everyone, happy new year & i really need your help with this Function:

pawn Код:
dcmd_v(playerid,params[])
{
                //Bla bla ...
        SpawnedV[playerid] = CreateVehicle(car, X,Y,Z, Angle, colour1, colour2, -1);
        format(string, sizeof(string), "Spawned Vehicle");
        vehicle3Dtext = Create3DTextLabel(string,RED,X,Y,Z,140.0,0);
        Attach3DTextLabelToVehicle(vehicle3Dtext, SpawnedV[playerid], 0.0, 0.0, 2.0);
    }
I need the SpawnedV[playerid] will destroy if PlayerDisconnect & if filterscript Exit.
And the 3D text will also hide.

Sorry for my bad Ang!
& So I hope someone will help me
Reply
#2

I have lately used:
pawn Код:
public OnFilterScriptExit()
{
    for(new playerid = 0; playerid < GetMaxPlayers(); playerid ++ )
    if(SpawnedV[playerid] == 1) {DestroyVehicle(SpawnedV[playerid]); Delete3DTextLabel(Text3D:vehicle3Dtext); }
    return 0;//1
}
pawn Код:
public OnPlayerDisconnect(playerid)
{
    if(SpawnedV[playerid] == 1){DestroyVehicle(SpawnedV[playerid]); Delete3DTextLabel(Text3D:vehicle3Dtext);}
    return 0;
}
But doesn't work
Reply
#3

Bump
Reply
#4

Any one !
Reply
#5

Hi,

First, change:
pawn Код:
Text3D:vehicle3Dtext;
to:
pawn Код:
Text3D:vehicle3Dtext[MAX_PLAYERS];
The command:
pawn Код:
dcmd_v(playerid,params[])
{
    if(SpanedV[playerid]!=0) return SendClientMessage(playerid, COLOR_RED, "ERROR: You already have a vehicle");
    //Bla bla ...
    SpawnedV[playerid] = CreateVehicle(car, X,Y,Z, Angle, colour1, colour2, -1);
    format(string, sizeof(string), "Spawned Vehicle");
    vehicle3Dtext[playerid] = Create3DTextLabel(string,RED,X,Y,Z,140.0,0);
    Attach3DTextLabelToVehicle(vehicle3Dtext[playerid], SpawnedV[playerid], 0.0, 0.0, 2.0);
    return 1;
}
OnFilterScriptExit:
pawn Код:
public OnFilterScriptExit()
{
    for(new playerid = 0; playerid < GetMaxPlayers(); playerid ++ )
    {
        if(SpawnedV[playerid] != -1)
        {
            DestroyVehicle(SpawnedV[playerid]);
            SpawnedV[playerid]=-1;
            Delete3DTextLabel(vehicle3Dtext[playerid]);
        }
    }
    return 1;
}
And OnPlayerDisconnect:
pawn Код:
public OnPlayerDisconnect(playerid)
{
    if(SpawnedV[playerid] != -1)
    {
        DestroyVehicle(SpawnedV[playerid]);
        SpawnedV[playerid]=-1;
        Delete3DTextLabel(vehicle3Dtext[playerid]);
    }
    return 1;
}
And you have to add under OnFilterScriptInit:
pawn Код:
public OnFilterScriptInit()
{
    for(new playerid = 0; playerid < GetMaxPlayers(); playerid ++ ) SpanedV[playerid]=-1;
    return 1;
}
If you have any questions, just ask.


Jeffry
Reply
#6

Jeffry, You're a high scripter
It's works very goood !

Question: Can you give me /callcar, for calling the SpawnedV ?! Thanks
If not, no prob
Reply
#7

Quote:
Originally Posted by Jeffry
Посмотреть сообщение
And you have to add under OnFilterScriptInit:
pawn Код:
public OnFilterScriptInit()
{
    for(new playerid = 0; playerid < GetMaxPlayers(); playerid ++ ) SpanedV[playerid]=-1;
    return 1;
}
Or you could do (just a tip):
pawn Код:
new
    SpawnedV[MAX_PLAYERS] = {-1,...};
    // Just like that (with the ellipsis in place). Will set every index in the array to -1 when it's created.
Reply
#8

Take a look at this: https://sampforum.blast.hk/showthread.php?tid=184505
Try something with it :P - And about calling:
You have this: car[playerid] = createvehicle blabla (something like that)
to get it, use carid 'car[playerid]'
Reply
#9

Quote:
Originally Posted by Vince
Посмотреть сообщение
Or you could do (just a tip):
pawn Код:
new
    SpawnedV[MAX_PLAYERS] = {-1,...};
    // Just like that (with the ellipsis in place). Will set every index in the array to -1 when it's created.
Learned something new today.

Quote:
Originally Posted by Yaszine
Посмотреть сообщение
Jeffry, You're a high scripter
Question: Can you give me /callcar, for calling the SpawnedV ?! Thanks
Do you mean, you type /callcar and YOUR SpawnedV Car will be set to your position?
Reply
#10

Quote:
Originally Posted by Jeffry
Посмотреть сообщение
Do you mean, you type /callcar and YOUR SpawnedV Car will be set to your position?
Yes for example: you tape /v Infernus, & someone has steal it, now you can do /callcar to call the stolen Car
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)