SA-MP Forums Archive
/towcar command not working... - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: /towcar command not working... (/showthread.php?tid=168040)



/towcar command not working... - Ash. - 14.08.2010

Hi guys and girls,

I have recently began rescripting my "assistance" job class section for my server, and have come accross a problem, i cannot get my /towcar command to work, it executes (because it doesnt say "SERVER: Unknown Command"), however it doesnt attach the car to the tow truck, can someone help?

Here is the "assistance" section of my OnPlayerCommandText callback:

pawn Код:
//Assistance...
    new Float:A_x, Float:A_y, Float:A_z;
    new A_Vehicle;
    if(strcmp("/assistance", cmdtext) == 0)
    {
        if(IsPlayerInAnyVehicle(playerid) == 1)
        {
            SendClientMessage(playerid, WORK, "Assistance has been called");
            SendClientMessage(playerid, WORK, "Just sit back, and wait!");
            //Call Assistance
            A_Vehicle = GetPlayerVehicleID(playerid);
            GetVehiclePos(A_Vehicle, A_x, A_y, A_z);
            new AssistanceMessage[128], PlayersName[128];
            GetPlayerName(playerid, PlayersName, sizeof(PlayersName));
            format(AssistanceMessage, sizeof(AssistanceMessage), "%s needs assistance, go and help!", PlayersName);
            for(new i; i < MAX_PLAYERS; i++)
            {
                if(GetPlayerTeam(i) == 2)
                {
                    SendClientMessage(i, WORK, AssistanceMessage);
                    SetPlayerCheckpoint(i, A_x, A_y, A_z, 15);
                }
            }
        }
        return 1;
    }

    if(strcmp("/repaircar", cmdtext) == 0)
    {
        if(GetPlayerTeam(playerid) == 2)
        {
            if(IsPlayerInRangeOfPoint(playerid, 15, A_x, A_y, A_z) == 1)
            {
                RepairVehicle(A_Vehicle);
                SetVehicleHealth(A_Vehicle, 100.0);
            }
        }
        return 1;
    }
   
    if(strcmp("/towcar", cmdtext) == 0)
    {
        if(GetPlayerTeam(playerid) == 2)
        {
            if(IsPlayerInRangeOfPoint(playerid, 15, A_x, A_y, A_z) == 1)
            {
                AttachTrailerToVehicle(A_Vehicle, GetPlayerVehicleID(playerid));
            }
        }
        return 1;
    }
    //------------------------------------------
I dont see whats wrong, unless its my A_Vehicle thing,
Can anyone else see the problem?

Thanks
Ash


Re: /towcar command not working... - Unforseen - 14.08.2010

try without GetPlayerTeam...

if(strcmp("/towcar", cmdtext) == 0)
{
if(IsPlayerInRangeOfPoint(playerid, 15, A_x, A_y, A_z) == 1)
{
AttachTrailerToVehicle(A_Vehicle, GetPlayerVehicleID(playerid));
}
else { SendClientMessage(playerid,color,"BLABLA"); }
return 1;
}

if it sends a message BLABLA.. then u are not near the point... if that worked try it with the GetPlayerTeam.

if it didnt work... there might be a problem from your previous commands