Portal SAMP
[Ajuda] Como fazer Pickup - Versão de Impressão

+- Portal SAMP (https://portalsamp.com)
+-- Fórum: SA-MP (https://portalsamp.com/forumdisplay.php?fid=5)
+--- Fórum: Área de suporte (https://portalsamp.com/forumdisplay.php?fid=6)
+--- Tópico: [Ajuda] Como fazer Pickup (/showthread.php?tid=4729)



Como fazer Pickup - Mateus Santos - 27/04/2024

Como coletar no spawn do veículo, muda automaticamente de forma aleatória (Pickup)
Código:
new trocarVeh;

new RandomVeh[] = {411, 400, 402, 404, 415, 418, 422, 424, 434, 444, 451, 457, 482, 495, 508, 514, 535, 541, 560, 573, 601, 571, 562};

OnGamemodeInit 
trocarVeh = CreatePickup(12957, 1, -1461.8420,-523.9481,14.1776, 0);

OnPlayerPickUpPickup
if (pickupid == trocarVeh)
{
    new vehicleId = AddStaticVehicle(RandomVeh[random(sizeof(RandomVeh))], -1449.7061,-526.0865,14.1719, 1, 1, 0);
   PutPlayerInVehicle(playerid, vehicleId, 0);
}
IMG
https://ibb.co/ryJ3GCP

Video, talvez 2 dias expirado D:
https://streamable.com/nsomqr

Os veículos não mudam automaticamente? sem OnFoot?, acho que funciona quando o OnFoot é trocado no veículo, tem como sem OnFoot?


RE: Como fazer Pickup - casti3l - 27/04/2024

if (pickupid == trocarVeh){
new rand = random(sizeof(RandomVeh));
new vehicleId = AddStaticVehicle(RandomVeh[rand], 817.2750,-1343.9915,13.5272, 1, 1, 0);
PutPlayerInVehicle(playerid, vehicleId, 0);
}


RE: Como fazer Pickup - samuelmatheus0502 - 27/04/2024

acho que você queria destruir o veiculo antigo certo?
se for isso use essa linha junto ao se código de criação do véiculo
Código:
// adcionado essa linha DestroyVehicle(vehicleId);
if (pickupid == trocarVeh){
DestroyVehicle(vehicleId);
new rand = random(sizeof(RandomVeh));
new vehicleId = AddStaticVehicle(RandomVeh[rand], 817.2750,-1343.9915,13.5272, 1, 1, 0);
PutPlayerInVehicle(playerid, vehicleId, 0);
}
você está usando um nome de variável que em algumas publics isso é parametro e não é muito legal, só uma dica mesmo... você poderia usar um nome mais interessante


RE: Como fazer Pickup - Carlos Victor - 27/04/2024

Código PHP:
new g_arrVehiclesRandom[] = {
    
411400402404415418422424434444451457482495508514535541560573601571562
};

new 
pickupChangeVehicle;
new 
gPlayerVehicle[MAX_PLAYERS];

public 
OnGameModeInit()
{
    
pickupChangeVehicle CreatePickup(129571, -1461.8420, -523.948114.17760);
    return 
1;
}

public 
OnPlayerDisconnect(playeridreason)
{
    if (
IsValidVehicle(gPlayerVehicle[playerid])) {
        
DestroyVehicle(gPlayerVehicle[playerid]);
        
gPlayerVehicle[playerid] = INVALID_VEHICLE_ID;
    }
    return 
1;
}

public 
OnPlayerPickUpPickup(playeridpickupid)
{
    if (
pickupid == pickupChangeVehicle && GetPlayerVehicleID(playerid) == gPlayerVehicle[playerid])
    {
        if (
IsValidVehicle(gPlayerVehicle[playerid]))
            
DestroyVehicle(gPlayerVehicle[playerid]);

        new 
            
gRandom random(sizeof(g_arrVehiclesRandom));

        
gPlayerVehicle[playerid] = AddStaticVehicle(g_arrVehiclesRandom[gRandom], -1449.7061,-526.0865,14.1719110);
           
PutPlayerInVehicle(playeridgPlayerVehicle[playerid], 0);
    }
    return 
1;




RE: Como fazer Pickup - Mateus Santos - 27/04/2024

Assim obrigado! vou pensa ckeckpoint https://www.open.mp/docs/scripting/functions/SetPlayerCheckpoint