[Help] Some cmd..
#1

Okay so, I got this command:

pawn Код:
if (strcmp(cmd, "/loadtrash", true) == 0)
{
    if(PlayerInfo[playerid][pJob] == 1)
    {
        new vehicle = GetPlayerClosestVehicle(5.0, playerid);
        if(vehicle)
        {
            if(IsGarbageTruck(vehicle))
            {
                Trash[vehicle] += gHasTrash[playerid];
                format(string, sizeof(string), "You have loaded %d trash into the trashmaster, trashmaster trash: %d/20", gHasTrash[playerid], Trash[vehicle]);
                SCM(playerid, 0x8CFFFFFF, string);
                gHasTrash[playerid] = 0;
            }
            else if(!IsGarbageTruck(vehicle))
            {
                SCM(playerid, COLOR_GREY, "You can only load trash into garbage trucks.");
            }
        }
        else
        {
            SCM(playerid, COLOR_GREY, "You are not near a garbage truck.");
        }
    }
    else
    {
        SCM(playerid, COLOR_GREY, "* You are not a garbage collector.");
    }
    return 1;
}
And I got a problem with it.
The problem is.. when I type the cmd and I'm near a garbage truck or not, it gives me this message:
"You can only load trash into garbage trucks."
Reply
#2

Try this code:

Код:
if (strcmp(cmdtext, "/loadtrash", true) == 0)
{    
	if(PlayerInfo[playerid][pJob] == 1)    
	{        
		new vehicle = GetPlayerClosestVehicle(5.0, playerid);        
		if(vehicle)        
		{
			if(!IsGarbageTruck(vehicle)) return SCM(playerid, COLOR_GREY, "You can only load trash into garbage trucks.");            
			
			Trash[vehicle] += gHasTrash[playerid];                
			format(string, sizeof(string), "You have loaded %d trash into the trashmaster, trashmaster trash: %d/20", gHasTrash[playerid], Trash[vehicle]);                				SCM(playerid, 0x8CFFFFFF, string);                
			gHasTrash[playerid] = 0;            
		}
		else return SCM(playerid, COLOR_GREY, "You are not near a garbage truck.");
	}                
	else return SCM(playerid, COLOR_GREY, "* You are not a garbage collector.");    
}
Reply
#3

Still the same
Reply
#4

try this
pawn Код:
if (strcmp(cmd, "/loadtrash", true) == 0)
{
    if(PlayerInfo[playerid][pJob] == 1)
    {
        new vehicle = GetPlayerClosestVehicle(5.0, playerid);
        if(vehicle)
        {
            if(IsGarbageTruck(vehicle))
            {
                Trash[vehicle] += gHasTrash[playerid];
                format(string, sizeof(string), "You have loaded %d trash into the trashmaster, trashmaster trash: %d/20", gHasTrash[playerid], Trash[vehicle]);
                SCM(playerid, 0x8CFFFFFF, string);
                gHasTrash[playerid] = 0;
            }
            else
            {
                SCM(playerid, COLOR_GREY, "You can only load trash into garbage trucks.");
            }
        }
        else
        {
            SCM(playerid, COLOR_GREY, "You are not near a garbage truck.");
        }
    }
    else
    {
        SCM(playerid, COLOR_GREY, "* You are not a garbage collector.");
    }
    return 1;
}
Reply
#5

Try it now:

Код:
if (strcmp(cmdtext, "/loadtrash", true) == 0)
{    
	if(PlayerInfo[playerid][pJob] != 1) return SCM(playerid, COLOR_GREY, "* You are not a garbage collector.");   
	        
	new vehicle = GetPlayerClosestVehicle(5.0, playerid);        
	if(vehicle)        
	{
		if(!IsGarbageTruck(vehicle)) return SCM(playerid, COLOR_GREY, "You can only load trash into garbage trucks and there seems to be none around you.");            
		
		Trash[vehicle] += gHasTrash[playerid];                
		format(string, sizeof(string), "You have loaded %d trash into the trashmaster, trashmaster trash: %d/20", gHasTrash[playerid], Trash[vehicle]);                				SCM(playerid, 0x8CFFFFFF, string);                
		gHasTrash[playerid] = 0;
	}            
	return 1;
}
Reply
#6

Still the same
Reply
#7

pawn Код:
if (strcmp(cmdtext, "/loadtrash", true) == 0)
{    
    if(PlayerInfo[playerid][pJob] != 1) return SCM(playerid, COLOR_GREY, "* You are not a garbage collector.");  
           
    new vehicle = GetPlayerClosestVehicle(5.0, playerid);        
    if(vehicle)        
    {
        if(GetVehicleModel(vehicle) != TRASHMASTER_MODEL_ID) return SCM(playerid, COLOR_GREY, "You can only load trash into garbage trucks and there seems to be none around you.");            
       
        Trash[vehicle] += gHasTrash[playerid];                
        format(string, sizeof(string), "You have loaded %d trash into the trashmaster, trashmaster trash: %d/20", gHasTrash[playerid], Trash[vehicle]);                             SCM(playerid, 0x8CFFFFFF, string);                
        gHasTrash[playerid] = 0;
    }            
    return 1;
}
Replace - TRASHMASTER_MODEL_ID with the modelid.
Reply
#8

Still the same :/
Reply
#9

Show the function :
Код:
IsGarbageTruck(vehicleid)
Reply
#10

pawn Код:
public IsGarbageTruck(carid)
{
    if(carid >= 81 && carid <= 84)
    {
        return 1;
    }
    return 0;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)