Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- CMD:vontat(playerid)
- {
- if(Belepve[playerid]!= 0)
- {
- if(IsPlayerInAnyVehicle(playerid))
- {
- new vehid = GetPlayerVehicleID(playerid);
- if(GetVehicleModel(vehid) == 525)
- {
- new kocsi = GetClosestVehicle(playerid);
- new id= -1;
- for(new x=0;x<MAX_VEHICLES;x++)
- {
- if(GetDistanceToVehicle(playerid, x) < 10)
- {
- if(id == -1)
- {
- id = x;
- }
- else
- {
- if(GetDistanceToVehicle(playerid,id) > GetDistanceToVehicle(playerid,x) && kocsi != x)
- {
- id=x;
- }
- }
- }
- }
- if(id == -1) return SendClientMessage(playerid, HIBA, "A közelben nincs jármű!");
- if(GetVehicleTrailer(vehid) == 0)
- {
- AttachTrailerToVehicle(id, vehid);
- SendClientMessage(playerid,SIKERES,"Felcsatolva.");
- new string[256];
- format(string,sizeof(string),"TESZT: Vontató: %d | Vontatni való: %d",kocsi,id);
- SendClientMessage(playerid,-1,string);
- return 1;
- }
- else
- {
- DetachTrailerFromVehicle(vehid);
- SendClientMessage(playerid,SIKERES,"Lecsatolva.");
- new string[256];
- format(string,sizeof(string),"TESZT: Vontató: %d | Vontatni való: %d",kocsi,id);
- SendClientMessage(playerid,-1,string);
- return 1;
- }
- }
- else SendClientMessage(playerid,HIBA,"Ez nem vontatókocsi!");
- }
- else SendClientMessage(playerid,HIBA,"Nem vagy autóban!");
- }
- else Logolj(playerid);
- return 1;
- }
- stock GetClosestVehicle(playerid)
- {
- #define ALAPKOCSI 1
- new kocsi = -1;
- if(IsPlayerInAnyVehicle(playerid)) kocsi = GetPlayerVehicleID(playerid);
- if(kocsi != -1)
- return kocsi;
- if(IsPlayerConnected(playerid) && IsVehicleConnected(ALAPKOCSI))
- {
- new closestvehicle=ALAPKOCSI;
- new Float:closestdist=GetDistanceToVehicle(playerid,ALAPKOCSI);
- for(new vehicleid=ALAPKOCSI; vehicleid<MAX_VEHICLES; vehicleid++)
- {
- new Float:dist = GetDistanceToVehicle(playerid,vehicleid);
- if(dist < closestdist)
- {
- if(kocsi == -1 || kocsi != -1 && kocsi != vehicleid)
- closestdist = dist;
- closestvehicle = vehicleid;
- }
- }
- return closestvehicle;
- }
- return -1;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement