SA-MP Forums Archive
Help! - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Help! (/showthread.php?tid=211175)



Help! - jaksimaksi - 14.01.2011

How to make that elegy get spawned when player selects from gui "drift" ?

here is my script:

pawn Код:
if(dialogid == 5)
{
if(response)
{
if(listitem == 0)
{
SetPlayerVirtualWorld(playerid, 2);
SetPlayerPos(playerid,-2421.2092,-610.8815,132.2896);
}
else if(listitem == 1)
{
SetPlayerHealth(playerid,0);
}
}



Re: Help! - JaTochNietDan - 14.01.2011

Assuming that listitem 0 is the one you're talking about?

pawn Код:
if(dialogid == 5)
{
    if(response)
    {
        if(listitem == 0)
        {
            SetPlayerVirtualWorld(playerid, 2);
            new tmpVehicle = CreateVehicle(562,-2421.2092,-610.8815,132.2896,0.0,0,0,100);
            SetVehicleVirtualWorld(tmpVehicle,2);
            PutPlayerInVehicle(playerid, tmpVehicle, 0);
        }
        else if(listitem == 1)
        {
            SetPlayerHealth(playerid,0);
        }
    }
}



Re: Help! - jaksimaksi - 14.01.2011

ty, one more question, im making a command /leave, to leave from drift and i want that when player types it, that vehicle gets destroyed?


Re: Help! - aircombat - 14.01.2011

DestroyVehicle(vehicleid);


AW: Help! - Kmitska - 14.01.2011

You can respawn the player if he/she writes /leave
pawn Код:
SpawnPlayer(playerid);
And it should be better if you respawn the vehicle instead of destoring:
pawn Код:
SetVehicleToRespawn(vehicleid);



Re: Help! - DeadAhead - 14.01.2011

Well, I suggest you using a global variable for this case. This i assume is a Temporary Vehicle, created only for one player, So i don't think you should respawn it. Example of what i mean

pawn Код:
if(dialogid == 5)
{
if(response)
{
if(listitem == 0)
{
SetPlayerVirtualWorld(playerid, 2);
SetPlayerPos(playerid,-2421.2092,-610.8815,132.2896);
PlVeh[playerid] = CreateVehicle(562,-2421.2092,-610.8815,132.2896,0.0,0,0,100);
}
else if(listitem == 1)
{
SetPlayerHealth(playerid,0);
}
}
In the Leave command:

pawn Код:
DestroyVehicle(PlVeh[playerid]);
PlVeh[playerid] = 0; // Reseting The Variable
And on the top of your script
pawn Код:
new PlVeh[MAX_PLAYERS];
And What else we need is to reset that variable and remove the vehicle if the player leaves the server:

(OnPlayerDisconnect)

pawn Код:
DestroyVehicle(PlVeh[playerid]);
PlVeh[playerid] = 0;
Now, this is a bit of a Simpler, but slower and a way i Do not Suggest , Professionally i would use an if Statement to check if PlVeh[playerid] is a valid vehicle.