towcar -
StR_MaRy - 16.10.2016
hey guys i have this cmd is supposed to tow the attached car to my trail if the car has under 900 hp but is not working i can tow a car with 1k health
Код HTML:
CMD:towcar(playerid, params[])
{
if(gLogged[playerid] == 0) return SendClientMessage(playerid, COLOR_ERROR, "Tu nu esti logat si nu poti sa folosesti aceasta comanda!");
if(PlayerInfo[playerid][pMember] + PlayerInfo[playerid][pLeader] != 6) return SendClientMessage(playerid, COLOR_ERROR, "Nu faci parte din Tow Truck Company.");
{
new vid = GetPlayerVehicleID(playerid);
if(GetPlayerState(playerid) != 2 && !IsATCCCar(vid)) return SendClientMessage(playerid, COLOR_ERROR, "You are not driver of a Tow Truck.");
if(GetVehicleModel(vid) != 525) return SendClientMessage(playerid, COLOR_ERROR, "You are not driver of a Tow Truck.");
if(IsTowing[playerid] == 1) return SendClientMessage(playerid, COLOR_ERROR, "You already towing a vehicle.");
if(PlayerInfo[playerid][pTowPoints] == 0) return SendClientMessage(playerid, COLOR_ERROR, "You cannot tow any car till PayDay.");
if(IsTrailerAttachedToVehicle(GetPlayerVehicleID(playerid)))
{
new Float:health;
new towedcar = GetVehicleTrailer(GetPlayerVehicleID(playerid));
GetVehicleHealth( towedcar, health );
if(health < 900.0)
{
format(gString, sizeof(gString), "Acel vehicul prezinta mai putin de 10%s daune, nu il poti tracta!", "%%");
SendClientMessage(playerid, COLOR_ERROR, gString );
return 1;
}
PlayerInfo[playerid][pTowPoints] --;
Update(playerid, pTowPointsx);
CP[playerid] = 90;
UseFind[playerid] = 0;
IsTowing[playerid] = 1;
SetPlayerCheckpoint(playerid, 2409.8416,-1425.7860,23.9826, 5.0);
SendClientMessage(playerid, COLOR_SYN2, "Go to the checkpoint and destroy the car.");
CP_Timer[playerid] = gettime();
}
else SendClientMessage(playerid, COLOR_ERROR, "You dont have a vehicle attached.");
}
return 1;
}
why?
Re: towcar -
Threshold - 17.10.2016
PHP код:
if(health < 900.0)
{
format(gString, sizeof(gString), "Acel vehicul prezinta mai putin de 10%s daune, nu il poti tracta!", "%%");
SendClientMessage(playerid, COLOR_ERROR, gString );
return 1;
}
This will return a message when you try to tow a vehicle with LESS than 900.0. Is this meant to be if(health > 900.0) ?
Re: towcar -
Marven - 17.10.2016
Код:
CMD:towcar(playerid, params[])
{
if(gLogged[playerid] == 0) return SendClientMessage(playerid, COLOR_ERROR, "Tu nu esti logat si nu poti sa folosesti aceasta comanda!");
if(PlayerInfo[playerid][pMember] + PlayerInfo[playerid][pLeader] != 6) return SendClientMessage(playerid, COLOR_ERROR, "Nu faci parte din Tow Truck Company.");
{
new vid = GetPlayerVehicleID(playerid);
if(GetPlayerState(playerid) != 2 && !IsATCCCar(vid)) return SendClientMessage(playerid, COLOR_ERROR, "You are not driver of a Tow Truck.");
if(GetVehicleModel(vid) != 525) return SendClientMessage(playerid, COLOR_ERROR, "You are not driver of a Tow Truck.");
if(IsTowing[playerid] == 1) return SendClientMessage(playerid, COLOR_ERROR, "You already towing a vehicle.");
if(PlayerInfo[playerid][pTowPoints] == 0) return SendClientMessage(playerid, COLOR_ERROR, "You cannot tow any car till PayDay.");
if(IsTrailerAttachedToVehicle(GetPlayerVehicleID(playerid)))
{
new Float:health;
new towedcar = GetVehicleTrailer(GetPlayerVehicleID(playerid));
GetVehicleHealth( towedcar, health );
if(health > 900.0)
{
format(gString, sizeof(gString), "Acel vehicul prezinta mai putin de 10%s daune, nu il poti tracta!", "%%");
SendClientMessage(playerid, COLOR_ERROR, gString );
return 1;
}
PlayerInfo[playerid][pTowPoints] --;
Update(playerid, pTowPointsx);
CP[playerid] = 90;
UseFind[playerid] = 0;
IsTowing[playerid] = 1;
SetPlayerCheckpoint(playerid, 2409.8416,-1425.7860,23.9826, 5.0);
SendClientMessage(playerid, COLOR_SYN2, "Go to the checkpoint and destroy the car.");
CP_Timer[playerid] = gettime();
}
else SendClientMessage(playerid, COLOR_ERROR, "You dont have a vehicle attached.");
}
return 1;
}
Код:
if(health > 900.0) //previously it was if(health < 900.0)
{
format(gString, sizeof(gString), "Acel vehicul prezinta mai putin de 10%s daune, nu il poti tracta!", "%%");
SendClientMessage(playerid, COLOR_ERROR, gString );
return 1;
}
This was the part in which you made a little mistake instead of if(health > 900.0) you typed if(health < 900) thats why it was sending you message on less than 900 health car and was towing above 900 hope it fixed your error.
Re: towcar -
StR_MaRy - 17.10.2016
i tryied to tow the car with full hp it's giving me the message is good but the thing is after that i smashed the car under 600 hp and still giving me the message "the car don't need to be towed is not damaged"
Re: towcar -
Threshold - 19.10.2016
Because
PHP код:
new towedcar = GetVehicleTrailer(GetPlayerVehicleID(playerid));
The trailer isn't attached yet...
Re: towcar -
StR_MaRy - 19.10.2016
if(IsTrailerAttachedToVehicle(GetPlayerVehicleID(p layerid)))
before that code you typed
Re: towcar -
Threshold - 19.10.2016
So... what is the purpose of /towcar?? The trailer is already attached? Then where do you attach the trailer?
Re: towcar -
StR_MaRy - 19.10.2016
the trailer is not already attached my friend i have a towcar and i press CLICK to attach it then i use /towcar , if i use this cmd without trailer i get "you have no trailer attached" so everything is fine just can't get the real hp from trailer
Re: towcar -
Threshold - 19.10.2016
Are you sure the HP is correct at the time you use /towcar? I can't remember, but doesn't the trailer get full health when it is attached, or is that my memory failing me?
Try typing /DL in-game and see if the trailer's health is still below 900.0 when you attach it.
Re: towcar -
StR_MaRy - 19.10.2016
no my friend the trailer is another car that is damaged by me or another player
photo:
http://imgur.com/a/2avxX