Server: Unknown Command.
#1

Problem:

When i type /tow and i'm not in a tow truck,i give the (correct) message: You are not in a tow truck.
But when i'n in this vehicle,i get the message: Server: Unknown command.

command:

Код:
CMD:tow(playerid, params[])
{
	if(gPlayerLogged[playerid] == 0) return SendClientMessage(playerid, COLOR_LIGHTRED, "Trebuie sa te loghezi inainte de a face asta.");
    if(IsPlayerConnected(playerid))
	{
	    if(PlayerInfo[playerid][pJob] == 8)
	    {
	        if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
	        {
	            new m = GetVehicleModel(GetPlayerVehicleID(playerid));
		    	if (m == 525)
	     	   	{
	     	   	    if(PlayerInfo[playerid][pJob] == 8) return 0;
                    if(GetPlayerVehicleID(playerid) == 525) return 0;
					if(GetPlayerState(playerid) == 2)
	     	   	    {
						new Float:pX,Float:pY,Float:pZ;
						GetPlayerPos(playerid,pX,pY,pZ);
						new Float:vX,Float:vY,Float:vZ;
						new Found=0;
						new vid=0;
						while((vid<MAX_VEHICLES)&&(!Found))
						{
		   					vid++;
		   					GetVehiclePos(vid,vX,vY,vZ);
		   					if ((floatabs(pX-vX)<7.0)&&(floatabs(pY-vY)<7.0)&&(floatabs(pZ-vZ)<7.0)&&(vid!=GetPlayerVehicleID(playerid)))
							{
								if(IsABike(vid) || GetVehicleModel(vid) == 448 || GetVehicleModel(vid) == 461 || GetVehicleModel(vid) == 462 || GetVehicleModel(vid) == 463 || GetVehicleModel(vid) == 468 || GetVehicleModel(vid) == 471 || GetVehicleModel(vid) == 521 || GetVehicleModel(vid) == 522 || GetVehicleModel(vid) == 523)
								{
								    return 1;
								}
								if(IsAnOwnableCar(vid))
								{
								    SCM(playerid,COLOR_WHITE,"Nu ai voie sa tractezi masini personale.");
								    return 1;
								}
								if(TowAcc[playerid] == 1) return SendClientMessage(playerid, COLOR_GREY, "Nu poti tracta atat de repede o masina, trebuie sa astepti 2 minute.");
							    Found=1;
		   				    	if(IsTrailerAttachedToVehicle(GetPlayerVehicleID(playerid)))
		           				{
		   				        	DetachTrailerFromVehicle(GetPlayerVehicleID(playerid));
                     				DisablePlayerCheckpoint(playerid);
                                    gPlayerCheckpointStatus[playerid] = CHECKPOINT_NONE;
						       	}
					           	else
					           	{
		    						AttachTrailerToVehicle(vid,GetPlayerVehicleID(playerid));
	                				new rand;
									rand = random(sizeof(TowCarCk));
						 		    SetPlayerCheckpoint(playerid, TowCarCk[rand][0],TowCarCk[rand][1],TowCarCk[rand][2], 6);
                         			CP[playerid] = 34;
								}
		 					}
		     			}
						if(!Found) return SendClientMessage(playerid, COLOR_GREY, "There is no car near to you.");
					}
					else return SendClientMessage(playerid, COLOR_GREY, "You need to be the driver.");
				}
				else return SendClientMessage(playerid, COLOR_GREY, "You need to be in a tow truck to use this command.");
			}
			else return SendClientMessage(playerid, COLOR_GREY, "You need to be in a tow truck to use this command.");
		}
		else return SendClientMessage(playerid, COLOR_GREY, "You need to be a mechanic to use this command.");
	}
	return 1;
}
Reply
#2

How many threads you wanna open

Why do you not stick to your threads?

Like that: https://sampforum.blast.hk/showthread.php?tid=664417
Reply
#3

Quote:
Originally Posted by Kaliber
Посмотреть сообщение
How many threads you wanna open

Why do you not stick to your threads?

Like that: https://sampforum.blast.hk/showthread.php?tid=664417
It's other code and other system.
Reply
#4

I've optimized the command for you:
pawn Код:
CMD:tow(playerid, params[])
{
    new Float:pX, Float:pY, Float:pZ, Float:vX,Float:vY,Float:vZ, Found, vid;
    if(!IsPlayerConnected(playerid)) return 0;
    if(APlayerData[playerid][LoggedIn] == false) return SendClientMessage(playerid, COLOR_LIGHTRED, "Trebuie sa te loghezi inainte de a face asta.");
    if(PlayerInfo[playerid][pJob] != 8) return SendClientMessage(playerid, COLOR_GREY, "You need to be a mechanic to use this command.");
    if(GetPlayerState(playerid) != PLAYER_STATE_DRIVER) return SendClientMessage(playerid, COLOR_GREY, "You need to be the driver to use this command.");
    if(GetVehicleModel(GetPlayerVehicleID(playerid)) != 525) return SendClientMessage(playerid, COLOR_GREY, "You need to be in a tow truck to use this command.");
    GetPlayerPos(playerid, pX, pY, pZ);
    while((vid<MAX_VEHICLES)&&(!Found))
    {
        vid++;
        GetVehiclePos(vid,vX,vY,vZ);
        if ((floatabs(pX-vX)<7.0)&&(floatabs(pY-vY)<7.0)&&(floatabs(pZ-vZ)<7.0)&&(vid!=GetPlayerVehicleID(playerid)))
        {
            if(IsABike(vid) || GetVehicleModel(vid) == 448 || GetVehicleModel(vid) == 461 || GetVehicleModel(vid) == 462 || GetVehicleModel(vid) == 463 || GetVehicleModel(vid) == 468 || GetVehicleModel(vid) == 471 || GetVehicleModel(vid) == 521 || GetVehicleModel(vid) == 522 || GetVehicleModel(vid) == 523) return 1;
            if(IsAnOwnableCar(vid)) return SendClientMessage(playerid, -1, "Nu ai voie sa tractezi masini personale.");
            if(TowAcc[playerid] == 1) return SendClientMessage(playerid, COLOR_GREY, "Nu poti tracta atat de repede o masina, trebuie sa astepti 2 minute.");
            Found = 1;
            if(IsTrailerAttachedToVehicle(GetPlayerVehicleID(playerid)))
            {
                DetachTrailerFromVehicle(GetPlayerVehicleID(playerid));
                DisablePlayerCheckpoint(playerid);
                gPlayerCheckpointStatus[playerid] = CHECKPOINT_NONE;
            }
            else
            {
                AttachTrailerToVehicle(vid,GetPlayerVehicleID(playerid));
                new rand = random(sizeof(TowCarCk));
                SetPlayerCheckpoint(playerid, TowCarCk[rand][0],TowCarCk[rand][1],TowCarCk[rand][2], 6);
                CP[playerid] = 34;
            }
        }
    }
    if(!Found) return SendClientMessage(playerid, COLOR_GREY, "There is no car near to you.");
    return 1;
}
Reply
#5

Quote:
Originally Posted by PPC23
Посмотреть сообщение
I've optimized the command for you:
pawn Код:
CMD:tow(playerid, params[])
{
    new Float:pX, Float:pY, Float:pZ, Float:vX,Float:vY,Float:vZ, Found, vid;
    if(!IsPlayerConnected(playerid)) return 0;
    if(APlayerData[playerid][LoggedIn] == false) return SendClientMessage(playerid, COLOR_LIGHTRED, "Trebuie sa te loghezi inainte de a face asta.");
    if(PlayerInfo[playerid][pJob] != 8) return SendClientMessage(playerid, COLOR_GREY, "You need to be a mechanic to use this command.");
    if(GetPlayerState(playerid) != PLAYER_STATE_DRIVER) return SendClientMessage(playerid, COLOR_GREY, "You need to be the driver to use this command.");
    if(GetVehicleModel(GetPlayerVehicleID(playerid)) != 525) return SendClientMessage(playerid, COLOR_GREY, "You need to be in a tow truck to use this command.");
    GetPlayerPos(playerid, pX, pY, pZ);
    while((vid<MAX_VEHICLES)&&(!Found))
    {
        vid++;
        GetVehiclePos(vid,vX,vY,vZ);
        if ((floatabs(pX-vX)<7.0)&&(floatabs(pY-vY)<7.0)&&(floatabs(pZ-vZ)<7.0)&&(vid!=GetPlayerVehicleID(playerid)))
        {
            if(IsABike(vid) || GetVehicleModel(vid) == 448 || GetVehicleModel(vid) == 461 || GetVehicleModel(vid) == 462 || GetVehicleModel(vid) == 463 || GetVehicleModel(vid) == 468 || GetVehicleModel(vid) == 471 || GetVehicleModel(vid) == 521 || GetVehicleModel(vid) == 522 || GetVehicleModel(vid) == 523) return 1;
            if(IsAnOwnableCar(vid)) return SendClientMessage(playerid, -1, "Nu ai voie sa tractezi masini personale.");
            if(TowAcc[playerid] == 1) return SendClientMessage(playerid, COLOR_GREY, "Nu poti tracta atat de repede o masina, trebuie sa astepti 2 minute.");
            Found = 1;
            if(IsTrailerAttachedToVehicle(GetPlayerVehicleID(playerid)))
            {
                DetachTrailerFromVehicle(GetPlayerVehicleID(playerid));
                DisablePlayerCheckpoint(playerid);
                gPlayerCheckpointStatus[playerid] = CHECKPOINT_NONE;
            }
            else
            {
                AttachTrailerToVehicle(vid,GetPlayerVehicleID(playerid));
                new rand = random(sizeof(TowCarCk));
                SetPlayerCheckpoint(playerid, TowCarCk[rand][0],TowCarCk[rand][1],TowCarCk[rand][2], 6);
                CP[playerid] = 34;
            }
        }
    }
    if(!Found) return SendClientMessage(playerid, COLOR_GREY, "There is no car near to you.");
    return 1;
}
Thanks,it's working. REP+!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)