Detect if player is near last vehicle
#1

Hi everyone, how to detect if the player is near the last entered vehicle?
this code is not working

pawn Код:
warning 213: tag mismatch
warning 202: number of arguments does not match definition
warning 202: number of arguments does not match definition
this is the line where i get the warnings
pawn Код:
GetVehicleBoot(vehicleid, x, y, z);
pawn Код:
if(strcmp(cmd, "/gettrash", true) == 0)
    {
        if(IsPlayerConnected(playerid))
        {
            if(IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid, 0xE74C3CFF, "{FFFFFF}You can't use this command in a vehicle.");
            new vehicleid = GetPVarInt(playerid, "LastVehicleID");
            if(GetVehicleModel(vehicleid) != 408) return SendClientMessage(playerid, 0xE74C3CFF, "{FFFFFF}Your last vehicle has to be a Trashmaster.");
            if(HasTrash[playerid]) return SendClientMessage(playerid, 0xE74C3CFF, "{FFFFFF}You're already carrying a trash bag.");
            new id = Trash_Closest(playerid);
            if(id == -1) return SendClientMessage(playerid, 0xE74C3CFF, "{FFFFFF}You're not near any trash.");
            if(TrashData[id][TrashLevel] < 1) return SendClientMessage(playerid, 0xE74C3CFF, "{FFFFFF}There's nothing here.");
            new Float: x, Float: y, Float: z;
            GetVehicleBoot(vehicleid, x, y, z);
            if(GetPlayerDistanceFromPoint(playerid, x, y, z) >= 30.0) return SendClientMessage(playerid, 0xE74C3CFF, "{FFFFFF}You're not near your Trashmaster.");
            TrashData[id][TrashLevel]--;
            KillTimer(TrashData[id][TrashTimer]);
            TrashData[id][TrashTimer] = SetTimerEx("FillTrash", REFILL_TIME * 1000, false, "i", id);
            TrashCP[playerid] = CreateDynamicCP(x, y, z, 3.0, .playerid = playerid);
            HasTrash[playerid] = true;
            ApplyAnimation(playerid, "CARRY", "liftup105", 4.1, 0, 0, 0, 0, 0);
            SetPlayerAttachedObject(playerid, ATTACHMENT_INDEX, 1264, 6, 0.222, 0.024, 0.128, 1.90, -90.0, 0.0, 0.5,0.5, 0.5);
            Streamer_SetIntData(STREAMER_TYPE_3D_TEXT_LABEL, TrashData[id][TrashLabel], E_STREAMER_COLOR, (TrashData[id][TrashLevel] == 0) ? 0xE74C3CFF : 0xF39C12FF);
            SendClientMessage(playerid, 0x2ECC71FF, "{FFFFFF}You can press {F39C12}~k~~CONVERSATION_NO~ {FFFFFF}to remove the trash bag.");
        }
        return 1;
    }
Reply
#2

Use
Код HTML:
IsPlayerNearVehicle(playerid, vehicleid, Float:range)
{
    new Float:X, Float:Y, Float:Z;
    GetVehiclePos(vehicleid, X, Y, Z);
    if(IsPlayerInRangeOfPoint(playerid, range, X, Y, Z))return true;
    else return false;
}
And check it with :

Код HTML:
IsPlayerNearVehicle(playerid, vehicleid, 10)
Reply
#3

That is not working for me
Reply
#4

Use it like:


Код HTML:
if(strcmp(cmd, "/gettrash", true) == 0)
	{
    	if(IsPlayerConnected(playerid))
    	{
			
			new vehicleid = GetPVarInt(playerid, "LastVehicleID");
			if(IsPlayerNearVehicle(playerid, vehicleid, 10))
			{
			if(IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid, 0xE74C3CFF, "{FFFFFF}You can't use this command in a vehicle.");
			if(GetVehicleModel(vehicleid) != 408) return SendClientMessage(playerid, 0xE74C3CFF, "{FFFFFF}Your last vehicle has to be a Trashmaster.");
    		if(HasTrash[playerid]) return SendClientMessage(playerid, 0xE74C3CFF, "{FFFFFF}You're already carrying a trash bag.");
			new id = Trash_Closest(playerid);
			if(id == -1) return SendClientMessage(playerid, 0xE74C3CFF, "{FFFFFF}You're not near any trash.");
			if(TrashData[id][TrashLevel] < 1) return SendClientMessage(playerid, 0xE74C3CFF, "{FFFFFF}There's nothing here.");
    		new Float: x, Float: y, Float: z;
    		GetVehicleBoot(vehicleid, x, y, z);
    		if(GetPlayerDistanceFromPoint(playerid, x, y, z) >= 30.0) return SendClientMessage(playerid, 0xE74C3CFF, "{FFFFFF}You're not near your Trashmaster.");
			TrashData[id][TrashLevel]--;
			KillTimer(TrashData[id][TrashTimer]);
    		TrashData[id][TrashTimer] = SetTimerEx("FillTrash", REFILL_TIME * 1000, false, "i", id);
			TrashCP[playerid] = CreateDynamicCP(x, y, z, 3.0, .playerid = playerid);
			HasTrash[playerid] = true;
			ApplyAnimation(playerid, "CARRY", "liftup105", 4.1, 0, 0, 0, 0, 0);
			SetPlayerAttachedObject(playerid, ATTACHMENT_INDEX, 1264, 6, 0.222, 0.024, 0.128, 1.90, -90.0, 0.0, 0.5,0.5, 0.5);
			Streamer_SetIntData(STREAMER_TYPE_3D_TEXT_LABEL, TrashData[id][TrashLabel], E_STREAMER_COLOR, (TrashData[id][TrashLevel] == 0) ? 0xE74C3CFF : 0xF39C12FF);
			SendClientMessage(playerid, 0x2ECC71FF, "{FFFFFF}You can press {F39C12}~k~~CONVERSATION_NO~ {FFFFFF}to remove the trash bag.");
			}
    	}
    	return 1;
	}
PS: Are you sure that the LastVehicleID gets the correct value?

Make a debug on it.

You can use a default variable like :
Код HTML:
new LastVeh[MAX_PLAYERS];
Go to
Код HTML:
public OnPlayerExitVehicle(playerid, vehicleid)
and use there
Код HTML:
LastVeh[playerid] = vehicleid;
After, use:



Код HTML:
if(strcmp(cmd, "/gettrash", true) == 0)
	{
    	if(IsPlayerConnected(playerid))
    	{

			new vehicleid = LastVeh[playerid];
			if(IsPlayerNearVehicle(playerid, vehicleid, 10))
			{
			if(IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid, 0xE74C3CFF, "{FFFFFF}You can't use this command in a vehicle.");
			if(GetVehicleModel(vehicleid) != 408) return SendClientMessage(playerid, 0xE74C3CFF, "{FFFFFF}Your last vehicle has to be a Trashmaster.");
    		if(HasTrash[playerid]) return SendClientMessage(playerid, 0xE74C3CFF, "{FFFFFF}You're already carrying a trash bag.");
			new id = Trash_Closest(playerid);
			if(id == -1) return SendClientMessage(playerid, 0xE74C3CFF, "{FFFFFF}You're not near any trash.");
			if(TrashData[id][TrashLevel] < 1) return SendClientMessage(playerid, 0xE74C3CFF, "{FFFFFF}There's nothing here.");
    		new Float: x, Float: y, Float: z;
    		GetVehicleBoot(vehicleid, x, y, z);
    		if(GetPlayerDistanceFromPoint(playerid, x, y, z) >= 30.0) return SendClientMessage(playerid, 0xE74C3CFF, "{FFFFFF}You're not near your Trashmaster.");
			TrashData[id][TrashLevel]--;
			KillTimer(TrashData[id][TrashTimer]);
    		TrashData[id][TrashTimer] = SetTimerEx("FillTrash", REFILL_TIME * 1000, false, "i", id);
			TrashCP[playerid] = CreateDynamicCP(x, y, z, 3.0, .playerid = playerid);
			HasTrash[playerid] = true;
			ApplyAnimation(playerid, "CARRY", "liftup105", 4.1, 0, 0, 0, 0, 0);
			SetPlayerAttachedObject(playerid, ATTACHMENT_INDEX, 1264, 6, 0.222, 0.024, 0.128, 1.90, -90.0, 0.0, 0.5,0.5, 0.5);
			Streamer_SetIntData(STREAMER_TYPE_3D_TEXT_LABEL, TrashData[id][TrashLabel], E_STREAMER_COLOR, (TrashData[id][TrashLevel] == 0) ? 0xE74C3CFF : 0xF39C12FF);
			SendClientMessage(playerid, 0x2ECC71FF, "{FFFFFF}You can press {F39C12}~k~~CONVERSATION_NO~ {FFFFFF}to remove the trash bag.");
			}
    	}
    	return 1;
	}
Reply
#5

Now i just got this error :error 017: undefined symbol "IsPlayerNearVehicle"
Reply
#6

Quote:
Originally Posted by MayaEU
Посмотреть сообщение
Now i just got this error :error 017: undefined symbol "IsPlayerNearVehicle"
Add somewhere:

Код HTML:
IsPlayerNearVehicle(playerid, vehicleid, Float:range)
{
    new Float:X, Float:Y, Float:Z;
    GetVehiclePos(vehicleid, X, Y, Z);
    if(IsPlayerInRangeOfPoint(playerid, range, X, Y, Z))return true;
    else return false;
}
Reply
#7

Well..

pawn Код:
warning 213: tag mismatch
warning 202: number of arguments does not match definition
warning 202: number of arguments does not match definition
and this is still the line with the problems:

pawn Код:
GetVehicleBoot(vehicleid, x, y, z);
Reply
#8

Anyone?
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)