[Pomoc]Attach kopacice i deattach

Započeo Sarkenzo, April 26, 2017, 07:56:11 PRE PODNE

prethodna tema - sledeća tema

0 članova i 1 gost pregledaju ovu temu.

Skripta koju koristim: Mod od 0
Detaljan opis problema: Kako da napravim da attach i deattach vozilo sa istim dugmetom, ja sam napravio nesto ali nije to to.Ovo su kordinate da mora da bude ispred vozila a ja hocu da gde god bilo to vozilo i igrac bio blizu njega kada stisne levi klik da se zakaci kopacica za traktor.
Dio skripte:

new vehicleid = GetPlayerVehicleID(playerid);
if(newkeys & KEY_FIRE)
{
if(GetVehicleModel( GetPlayerVehicleID( playerid ) ) == 531 && IgracevInfo[playerid][uPosao] == 16 && Oprema[playerid] == 14)
{
if(IsPlayerInRangeOfPoint(playerid, 2.0, -1090.2968,-1172.1434,129.1832))
{
if(!IsTrailerAttachedToVehicle(vehicleid))
{
SCM NZM"Zakacili ste kopacicu");
AttachTrailerToVehicle(Kopacica[1], vehicleid);
Freziranje(playerid);
}
if(IsTrailerAttachedToVehicle(vehicleid))
{
DetachTrailerFromVehicle(vehicleid);
SCM NZM"Otkacili ste kopacicu");
}
return 1;
}
}
}

if(newkeys & KEY_FIRE)
{
if(GetVehicleModel( GetPlayerVehicleID( playerid ) ) == 531 && IgracevInfo[playerid][uPosao] == 16 && Oprema[playerid] == 14)
{
if(IsPlayerInRangeOfPoint(playerid, 2.0, -1090.2749,-1168.4711,129.1854))
{
if(!IsTrailerAttachedToVehicle(vehicleid))
{
SCM NZM"Zakacili ste kopacicu");
AttachTrailerToVehicle(Kopacica[2], vehicleid);
Freziranje(playerid);
}
if(IsTrailerAttachedToVehicle(vehicleid))
{
DetachTrailerFromVehicle(vehicleid);
SCM NZM"Otkacili ste kopacicu");
}
return 1;
}
}
}

if(newkeys & KEY_FIRE)
{
if(GetVehicleModel( GetPlayerVehicleID( playerid ) ) == 531 && IgracevInfo[playerid][uPosao] == 16 && Oprema[playerid] == 14)
{
if(IsPlayerInRangeOfPoint(playerid, 2.0, -1090.2787,-1164.7446,129.1848))
{
if(!IsTrailerAttachedToVehicle(vehicleid))
{
SCM NZM"Zakacili ste kopacicu");
AttachTrailerToVehicle(Kopacica[3], vehicleid);
Freziranje(playerid);
}
if(IsTrailerAttachedToVehicle(vehicleid))
{
DetachTrailerFromVehicle(vehicleid);
SCM NZM"Otkacili ste kopacicu");
}
return 1;
}
}
}

if(newkeys & KEY_FIRE)
{
if(GetVehicleModel( GetPlayerVehicleID( playerid ) ) == 531 && IgracevInfo[playerid][uPosao] == 16 && Oprema[playerid] == 14)
{
if(IsPlayerInRangeOfPoint(playerid, 2.0, -1090.2810,-1160.4926,129.1837))
{
if(!IsTrailerAttachedToVehicle(vehicleid))
{
SCM NZM"Zakacili ste kopacicu");
AttachTrailerToVehicle(Kopacica[4], vehicleid);
Freziranje(playerid);
}
if(IsTrailerAttachedToVehicle(vehicleid))
{
DetachTrailerFromVehicle(vehicleid);
SCM NZM"Otkacili ste kopacicu");
}
return 1;
}
}
}

Tako nesto treba ali kada zamenim getplayervehicleid sa ovim nece da zakaci nijedno vozilo

if(newkeys & KEY_ACTION)
{
if(IsPlayerInAnyVehicle(playerid) && GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
{
if(VozilaAM2(GetPlayerVehicleID(playerid)))
{
new Float:pX, Float:pY, Float:pZ;
GetPlayerPos(playerid, pX, pY, pZ);
new Float:vX1, Float:vY1, Float:vZ1;
new Found = 0, vid = 0;
while((vid < MAX_VOZILA) && (!Found))
{
vid++;
GetVehiclePos(vid,vX1,vY1,vZ1);
if((floatabs(pX - vX1) < 7.0) && (floatabs(pY - vY1) < 7.0) && (floatabs(pZ - vZ1) < 7.0) && (vid != GetPlayerVehicleID(playerid)))//GetVehicleTrailer(vehicleid);
{
Found = 1;
if(IsTrailerAttachedToVehicle(GetPlayerVehicleID(playerid))) GetVehicleTrailer(vehicleid);
{
DetachTrailerFromVehicle(GetPlayerVehicleID(playerid)); GetVehicleTrailer(vehicleid);
SCM(playerid,-1,"Vozilo je otkaceno!");
}
else
{
AttachTrailerToVehicle(vid, GetPlayerVehicleID(playerid)); GetVehicleTrailer(vehicleid);
SCM(playerid,-1,"Vozilo je zakaceno!");
}
}
}
if(!Found)
{
SCM(playerid,-1,"Nema vozila u blizini!");
}
}
}
}
}


dodaj return 1; na svaku izvrsenu radnju. Trebalo bi radit, jer radi provjeru dali je vozilo zakaceno, i ako nije zakaci ga, a ispod odmah radi provjeru ako je zakaceno da ga otkaci..
if(!IsTrailerAttachedToVehicle(vehicleid))
{
SCM NZM"Zakacili ste kopacicu");
AttachTrailerToVehicle(Kopacica[1], vehicleid);
Freziranje(playerid);
return 1;// Tako dodaj na svaku izvrsenu radnju
}