[TUT/FS]Carros ( Completo )

Criando Carros ( Completo )

Topo do GM/FS

new CarrosPs[MAX_PLAYERS];

public OnPlayerCommandText

if (strcmp(cmdtext, "/carros", true) == 0)
{
ShowPlayerDialog(playerid,158,DIALOG_STYLE_LIST,"Pegar carros","\nElegy\nNRG-500","Ok","Sair");
return 1;
}

public OnDialogResponse

if(dialogid == 158)
{
if(response)
{
if(listitem == 0)
{
if(CarrosPs[playerid] != INVALID_VEHICLE_ID)
DestroyVehicle(CarrosPs[playerid]);
new Float:X,Float:Y,Float:Z,Float:Angle;
GetPlayerPos(playerid,X,Y,Z);
GetPlayerFacingAngle(playerid,Angle);
GetPlayerVehicleID(playerid);
CarrosPs[playerid] = CreateVehicle(562,X,Y,Z,Angle,-1,-1,600);
PutPlayerInVehicle(playerid, CarrosPs[playerid], 0);
}
}
if(listitem == 1)
{
if(CarrosPs[playerid] != INVALID_VEHICLE_ID)
DestroyVehicle(CarrosPs[playerid]);
new Float:X,Float:Y,Float:Z,Float:Angle;
GetPlayerPos(playerid,X,Y,Z);
GetPlayerFacingAngle(playerid,Angle);
GetPlayerVehicleID(playerid);
CarrosPs[playerid] = CreateVehicle(522,X,Y,Z,Angle,-1,-1,600);
PutPlayerInVehicle(playerid, CarrosPs[playerid], 0);
}
}


public OnPlayerExitVehicle

SetTimerEx("psDestroyVehicle", 20000, 0, "i", vehicleid);

Final do GM/FS

forward psDestroyVehicle(vehicleid);
public psDestroyVehicle(vehicleid)
{
return DestroyVehicle(vehicleid);
}

Assim, quando o player criar um carro, e tentar criar outro, o outro carro ira sumir, e iria ficar com o novo carro..

Se o player sair do carro, e ficar 20 segundos fora, o carro vai desaparecer.. Isto é bom para que se o player sair do Servidor, ai o carro ira sumir.

PS : PawnSamp

Ai você pode mudar a id dos veiculos, adicionar/remover veiculos e enfim..


By: GTA

StumbleDiggTechnoratiRedditDelicious