Jump to content
  • 0

pomoc Práce S Vozidlem


ForestCZE

Dotaz

Ahoj :)

 

Snažím se vytvořit vozidlo pro jednotlivého hráče se zamknutím vozidla a pak když ho zničí, aby se už neobjevilo ;)

 

Mám proměnnou:

 

Vozidlo[MAX_PLAYERS];

 

Vytvoření auta + zamknutí:

 

Vozidlo[playerid] = CreateVehicle(411,-1650.5533,1222.3875,6.8352,42.9428,64,1,5000);

for(new all = 0; all < MAX_PLAYERS; all++){
if(IsPlayerConnected(all)){
if(all != playerid){
SetVehicleParamsForPlayer(Vozidlo[playerid], all, 0, 1);
}
}
}

 

Zamknutí nefunguje :X

 

A pak chci, aby se po buchnutí auta už neobjevilo ... mám:

 


public OnVehicleDeath(vehicleid, killerid)
{
DestroyVehicle(Vozidlo[killerid]);
return true;
}

 

To auto se stejně objeví na původní pozici. Kde je chyba? Díky :)

Link to comment
Share on other sites

6 odpovědí na tuto otázku

Recommended Posts

  • 0

funkciu SetVehicleParamsForPlayer( som nikdy nepoužil takže to nwm, ja som to riešil cez GetPlayerStateChange a to vozidlo, to zmazanie musíš dať do OnVehicleSpawn ale daj tam timer na pár ms lebo viem že aj tam bol nejaký problém (ak si spomínam tak sa auto respawne 2x preto tam nešiel dať tuning alebo tak nejak) a nezabudni tam dať cyklus for(...){ if(Vozidlo == vehicleid){ SetTimerEx("delete",100,false,"i",i); break;}} a tam to čo máš v OnVehicleDeath...

 

GetPlayerStateChange ... to myslíš GetPlayerState?? Ale nevím jak s tím ...

Link to comment
Share on other sites

  • 0

A nestačilo by prostě místo tady

CreateVehicle(411,-1650.5533,1222.3875,6.8352,42.9428,64,1,5000);

Místo toho 5000 na konci dat prostě -1 ? Zkus si to.

 

 

To nepomáhá ;)

 

 

Preklep, myslel som callback "OnPlayerStateChange"

 

Vůbec nevím jak tam udělat zamykání .. to jde?

Link to comment
Share on other sites

  • 0

public OnPlayerStateChange(playerid,newstate,oldstate){

if(newstate == PLAYER_STATE_DRIVER){

new car = GetPlayerVehicleID(playerid);

for(new i; i < MAX_PLAYERS;i++){

if(Vozidlo == car && i != playerid){

RemovePlayerFromVehicle(playerid);

}

}

}

return true;

}

 

No jasné, RemovePlayerFromVehicle mě opravdu nenapadlo :) díky :)

 

RemovePlayerFromVehicle(playerid);

 

Nemá to být:

 

RemovePlayerFromVehicle(i);

 

??? :d

Link to comment
Share on other sites

  • 0

killerid neni ten kdo vozidlo vytvoril, ale ten kdo ho znicil

 

Lze to resit takto:

 

new MajitelVozidla[MAX_VEHICLES];

 

do OnGameModeInit

for(new v;v<MAX_VEHICLES;v++) MajitelVozidla[v] = -1;

 

Vozidlo[playerid] = CreateVehicle(411,-1650.5533,1222.3875,6.8352,42.9428,64,1,5000);
MajitelVozidla[Vozidlo[playerid]] = playerid;
for(new all = 0; all < MAX_PLAYERS; all++){
if(IsPlayerConnected(all)){
if(all != playerid){
SetVehicleParamsForPlayer(Vozidlo[playerid], all, 0, 1);
}
}
}

 

public OnVehicleDeath(vehicleid, killerid)
{
if(MajitelVozidla[vehicleid] > -1)
{
MajitelVozidla[vehicleid] = -1
DestroyVehicle(vehicleid);
}
return true;
}

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...