command isn't working...
#1

Hello, I have made a setvehiclehealth command but for some reason I can't use option to use vehicle ID and the command is not even working

Command:
PHP код:
CMD:setvehiclehealth(playeridparams[])
{
    if(
PlayerInfo[playerid][pAdmin] < 3)
    {
    new 
VehicleHealthstring[125];
    new 
vehicleid GetPlayerVehicleID(playerid);
    if(
sscanf(params"f"VehicleHealth)) return SendClientMessage(playeridCOLOR_GREEN"/setvehiclehealth [Health]");
    
format(stringsizeof(string),"You have set your vehicle health to %f",VehicleHealth);
    
SendClientMessage(playeridCOLOR_GRAD1string);
    
SetVehicleHealth(vehicleid,VehicleHealth);
    }
    return 
1;

Reply
#2

You need to change
Код:
newVehicleHealth, string[125];
To
Код:
new Float:VehicleHealth, string[125];
Because health is a float you need to create the variable as a float.
Reply
#3

So I have edited the command like you said.

The health is still the same after I edit the health number see screenshots:

http://imgur.com/PAJhotr
http://imgur.com/mT2ZqUP

The command:

PHP код:
CMD:setvehiclehealth(playeridparams[])
{
    if(
PlayerInfo[playerid][pAdmin] < 3)
    {
        
SendClientMessage(playeridCOLOR_GREY"You're not allowed to use this command.");
    }
    if(
AdminDuty[playerid] != && PlayerInfo[playerid][pAdmin] < 6)
    {
        
SendClientMessage(playerid,COLOR_WHITE"You're not on-duty as admin. To access your admin commands you must be on-duty. Type /aduty to go on-duty.");
    }
    new 
Float:VehicleHealthstring[125];
    new 
vehicleid GetPlayerVehicleID(playerid);
    if(
sscanf(params"fd"Float:VehicleHealthvehicleid)) return SendClientMessage(playeridCOLOR_GREEN"/setvehiclehealth [Health] [VehicleID]");
    
format(stringsizeof(string),"You have set your vehicle health to %f",Float:VehicleHealth);
    
SendClientMessage(playeridCOLOR_GRAD1string);
    
SetVehicleHealth(vehicleidFloat:VehicleHealth);
    return 
1;

Reply
#4

Quote:
Originally Posted by SacrificeGaming
Посмотреть сообщение
So I have edited the command like you said.

The health is still the same after I edit the health number see screenshots:

http://imgur.com/PAJhotr
http://imgur.com/mT2ZqUP

The command:

PHP код:
CMD:setvehiclehealth(playeridparams[])
{
    if(
PlayerInfo[playerid][pAdmin] < 3)
    {
        
SendClientMessage(playeridCOLOR_GREY"You're not allowed to use this command.");
    }
    if(
AdminDuty[playerid] != && PlayerInfo[playerid][pAdmin] < 6)
    {
        
SendClientMessage(playerid,COLOR_WHITE"You're not on-duty as admin. To access your admin commands you must be on-duty. Type /aduty to go on-duty.");
    }
    new 
Float:VehicleHealthstring[125];
    new 
vehicleid GetPlayerVehicleID(playerid);
    if(
sscanf(params"fd"Float:VehicleHealthvehicleid)) return SendClientMessage(playeridCOLOR_GREEN"/setvehiclehealth [Health] [VehicleID]");
    
format(stringsizeof(string),"You have set your vehicle health to %f",Float:VehicleHealth);
    
SendClientMessage(playeridCOLOR_GRAD1string);
    
SetVehicleHealth(vehicleidFloat:VehicleHealth);
    return 
1;

You changed more than just the line I showed you. Try this:

This command will set the health of the vehicle ID that you specify.
Код:
CMD:setvehiclehealth(playerid, params[])
{
    if(PlayerInfo[playerid][pAdmin] < 3)
    {
        SendClientMessage(playerid, COLOR_GREY, "You're not allowed to use this command.");
    }
    if(AdminDuty[playerid] != 1 && PlayerInfo[playerid][pAdmin] < 6)
    {
        SendClientMessage(playerid,COLOR_WHITE, "You're not on-duty as admin. To access your admin commands you must be on-duty. Type /aduty to go on-duty.");
    }
    new Float:VehicleHealth, string[125], vehicleid;
    if(sscanf(params, "fd", VehicleHealth, vehicleid)) return SendClientMessage(playerid, COLOR_GREEN, "/setvehiclehealth [Health] [VehicleID]");
    format(string, sizeof(string),"You have set vehicle id %d  health to %f", vehicleid, VehicleHealth);
    SendClientMessage(playerid, COLOR_GRAD1, string);
    SetVehicleHealth(vehicleid, VehicleHealth);
    return 1;
}
This command will set the health of the vehicle you are in.
Код:
CMD:setmyvehiclehealth(playerid, params[])
{
    if(PlayerInfo[playerid][pAdmin] < 3)
    {
        SendClientMessage(playerid, COLOR_GREY, "You're not allowed to use this command.");
    }
    if(AdminDuty[playerid] != 1 && PlayerInfo[playerid][pAdmin] < 6)
    {
        SendClientMessage(playerid,COLOR_WHITE, "You're not on-duty as admin. To access your admin commands you must be on-duty. Type /aduty to go on-duty.");
    }
    new Float:VehicleHealth, string[125];
    new vehicleid = GetPlayerVehicleID(playerid);
    if(sscanf(params, "f", VehicleHealth)) return SendClientMessage(playerid, COLOR_GREEN, "/setmyvehiclehealth [Health]");
    format(string, sizeof(string),"You have set your vehicle health to %f", VehicleHealth);
    SendClientMessage(playerid, COLOR_GRAD1, string);
    SetVehicleHealth(vehicleid, VehicleHealth);
    return 1;
}
Reply
#5

Get you a woman that can do both.

PHP код:
CMD:setvehiclehealth(playeridparams[])
{
    if(
PlayerInfo[playerid][pAdmin] < 3)
    {
        new
            
Float:VehicleHealth,
            
vehicleid
        
;
        if(
sscanf(params"fD(0)"VehicleHealthvehicleid)) return SendClientMessage(playeridCOLOR_GREEN"/setvehiclehealth [Health] [Optional: Vehicle ID]");
        
vehicleid = (vehicleid) ? (vehicleid) : (GetPlayerVehicleID(playerid));
        if(!
vehicleid) return SendClientMessage(playeridCOLOR_GREEN"You must be in a vehicle or enter a vehicle ID to use this command.");
        new 
string[50];
        
format(stringsizeof(string), "You have set vehicle ID %d's health to %f"vehicleidVehicleHealth);
        
SendClientMessage(playeridCOLOR_GRAD1string);
        
SetVehicleHealth(vehicleidVehicleHealth);
    }
    return 
1;

Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)