SA-MP Forums Archive
Repair PickupID - 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)
+--- Thread: Repair PickupID (/showthread.php?tid=656095)



Repair PickupID - DerickClark - 07.07.2018

When i created PickupID: 0 then created PickupID 1. Then i type /repair shows me
Код:
if(!IsPlayerAtRepair(playerid)) SendClientMessage(playerid, COLOUR_RED, "You are not at repair station.");
Код:
enum aInfo
{
    PickupID,
    Float: pux,
    Float: puy,
    Float: puz,
    Text3D: TextLabel
};
new ARepairPickups[MAX_REPAIR_PICKUPS][aInfo];

AddARepairPickups(Float:x, Float:y, Float:z)
{
    for (new i; i < sizeof(ARepairPickups); i++)
    {
        if (ARepairPickups[i][PickupID] == 0)
        {
            ARepairPickups[i][PickupID] = CreatePickup(3096, 1, x, y, z, 0);
            ARepairPickups[i][pux] = x;
            ARepairPickups[i][puy] = y;
            ARepairPickups[i][puz] = z;
            Create3DTextLabel("{FFFF00}Type {00FF00}/repair {FFFF00}to repair your vehicle!", -1, x, y, z +0.5, 50.0, 0);
            CreateDynamicMapIcon(x, y, z, 63, 0, 0, 0, -1, 300.0);
            break;
        }
    }
}

bool:IsPlayerAtRepair(playerid)
{

    for(new i; i != sizeof(ARepairPickups); i++)
        if(IsPlayerInRangeOfPoint(playerid, 5.0, ARepairPickups[i][pux], ARepairPickups[i][puy], ARepairPickups[i][puz]))
            return true;

    return false;
}
CMD:createrepair(playerid, params[])
{
   new Float:x, Float:y, Float:z;
   if(PlayerInfo[playerid][pAdmin] < 2) return SendClientMessage(playerid, COLOUR_RED, "Administrator status required.");
   GetPlayerPos(playerid, x, y, z);
   AddARepairPickups(x, y, z);
   return 1;
}

CMD:repair(playerid, params[])
{
    SendMessageToAdmins(playerid, "repair", params);
    if(!IsPlayerAtRepair(playerid)) SendClientMessage(playerid, COLOUR_RED, "You are not at repair station.");
    else if(GetPlayerVehicleSeat(playerid) != 0) SendClientMessage(playerid, COLOUR_RED, "You are not in a vehicle.");
    else{
        SetTimerEx("Repair", 5000, false, "i", playerid);
        TogglePlayerControllable(playerid, 0);
        GameTextForPlayer(playerid, "~r~Fixing...~n~Please Wait...", 7000, 6);
    }
    return 1;
}



Re: Repair PickupID - DerickClark - 07.07.2018

Still didn't find the problem


Re: Repair PickupID - Jefff - 07.07.2018

You need use prints to see whats is wrong and also check valid pickupid


Re: Repair PickupID - DerickClark - 07.07.2018

Quote:
Originally Posted by Jefff
Посмотреть сообщение
You need use prints to see whats is wrong and also check valid pickupid
How do i get print?

Код:
            printf(ARepairPickups[i][PickupID]);



Re: Repair PickupID - Jefff - 08.07.2018

pawn Код:
AddARepairPickups(Float:x, Float:y, Float:z)
{
    for (new i; i < sizeof(ARepairPickups); i++)
    {
        if (ARepairPickups[i][PickupID] == 0)
        {
            ARepairPickups[i][PickupID] = CreatePickup(3096, 1, x, y, z, 0);
            ARepairPickups[i][pux] = x;
            ARepairPickups[i][puy] = y;
            ARepairPickups[i][puz] = z;
            Create3DTextLabel("{FFFF00}Type {00FF00}/repair {FFFF00}to repair your vehicle!", -1, x, y, z +0.5, 50.0, 0);
            CreateDynamicMapIcon(x, y, z, 63, 0, 0, 0, -1, 300.0);
            printf("PickupID: %d, PosX: %.4f, PosY: %.4f, PosZ: %.4f",ARepairPickups[i][PickupID],x,y,z);
            break;
        }
    }
}

bool:IsPlayerAtRepair(playerid)
{
    for(new i; i != sizeof(ARepairPickups); i++)
    {
        if(ARepairPickups[i][PickupID] != 0)
        {
            printf("IsPlayerAtRepair: PosX: %.4f, PosY: %.4f, PosZ: %.4f",ARepairPickups[i][pux], ARepairPickups[i][puy], ARepairPickups[i][puz]);
        }

        if(ARepairPickups[i][PickupID] != 0 && IsPlayerInRangeOfPoint(playerid, 5.0, ARepairPickups[i][pux], ARepairPickups[i][puy], ARepairPickups[i][puz]))
            return true;
    }

    return false;
}



Re: Repair PickupID - DerickClark - 08.07.2018

Quote:
Originally Posted by Jefff
Посмотреть сообщение
pawn Код:
AddARepairPickups(Float:x, Float:y, Float:z)
{
    for (new i; i < sizeof(ARepairPickups); i++)
    {
        if (ARepairPickups[i][PickupID] == 0)
        {
            ARepairPickups[i][PickupID] = CreatePickup(3096, 1, x, y, z, 0);
            ARepairPickups[i][pux] = x;
            ARepairPickups[i][puy] = y;
            ARepairPickups[i][puz] = z;
            Create3DTextLabel("{FFFF00}Type {00FF00}/repair {FFFF00}to repair your vehicle!", -1, x, y, z +0.5, 50.0, 0);
            CreateDynamicMapIcon(x, y, z, 63, 0, 0, 0, -1, 300.0);
            printf("PickupID: %d, PosX: %.4f, PosY: %.4f, PosZ: %.4f",ARepairPickups[i][PickupID],x,y,z);
            break;
        }
    }
}

bool:IsPlayerAtRepair(playerid)
{
    for(new i; i != sizeof(ARepairPickups); i++)
    {
        if(ARepairPickups[i][PickupID] != 0)
        {
            printf("IsPlayerAtRepair: PosX: %.4f, PosY: %.4f, PosZ: %.4f",ARepairPickups[i][pux], ARepairPickups[i][puy], ARepairPickups[i][puz]);
        }

        if(ARepairPickups[i][PickupID] != 0 && IsPlayerInRangeOfPoint(playerid, 5.0, ARepairPickups[i][pux], ARepairPickups[i][puy], ARepairPickups[i][puz]))
            return true;
    }

    return false;
}
Код:
[19:37:17] PickupID: 0, PosX: -2030.8498, PosY: 179.5177, PosZ: 28.8359
[19:37:39] PickupID: 1, PosX: -2013.6981, PosY: 173.5250, PosZ: 27.6798
[19:40:20] IsPlayerAtRepair: PosX: -2013.6981, PosY: 173.5250, PosZ: 27.6798
[19:40:22] IsPlayerAtRepair: PosX: -2013.6981, PosY: 173.5250, PosZ: 27.6798
[19:40:27] IsPlayerAtRepair: PosX: -2013.6981, PosY: 173.5250, PosZ: 27.6798



Re: Repair PickupID - Jefff - 08.07.2018

So pickupids starts from 0, you need set all ARepairPickups[i][PickupID] to -1 before loading pickups and change == 0 to == -1


Re: Repair PickupID - DerickClark - 08.07.2018

Quote:
Originally Posted by Jefff
Посмотреть сообщение
So pickupids starts from 0, you need set all ARepairPickups[i][PickupID] to -1 before loading pickups and change == 0 to != -1
when i use /repair it don't create it
Код:
enum aInfo
{
    PickupID,
    Float: pux,
    Float: puy,
    Float: puz,
    Text3D: TextLabel
};
new ARepairPickups[MAX_REPAIR_PICKUPS][aInfo];

AddARepairPickups(Float:x, Float:y, Float:z)
{
	for (new i; i < sizeof(ARepairPickups); i++)
	{
		if (ARepairPickups[i][PickupID] == -1)
		{
			ARepairPickups[i][PickupID] = CreatePickup(3096, 1, x, y, z, 0);
			ARepairPickups[i][pux] = x;
			ARepairPickups[i][puy] = y;
			ARepairPickups[i][puz] = z;
			Create3DTextLabel("{FFFF00}Type {00FF00}/repair {FFFF00}to repair your vehicle!", -1, x, y, z +0.5, 50.0, 0);
			CreateDynamicMapIcon(x, y, z, 63, 0, 0, 0, -1, 300.0);
			printf("PickupID: %d, PosX: %.4f, PosY: %.4f, PosZ: %.4f",ARepairPickups[i][PickupID],x,y,z);
			break;
		}
	}
}

bool:IsPlayerAtRepair(playerid)
{
	for(new i; i != sizeof(ARepairPickups); i++)
	{
		if(ARepairPickups[i][PickupID] != -1)
		{
			printf("IsPlayerAtRepair: PosX: %.4f, PosY: %.4f, PosZ: %.4f",ARepairPickups[i][pux], ARepairPickups[i][puy], ARepairPickups[i][puz]);
		}

		if(ARepairPickups[i][PickupID] != -1 && IsPlayerInRangeOfPoint(playerid, 5.0, ARepairPickups[i][pux], ARepairPickups[i][puy], ARepairPickups[i][puz]))
			return true;
	}

	return false;
}

CMD:createrepair(playerid, params[])
{
   new Float:x, Float:y, Float:z;
   if(PlayerInfo[playerid][pAdmin] < 2) return SendClientMessage(playerid, COLOUR_RED, "Administrator status required.");
   GetPlayerPos(playerid, x, y, z);
   AddARepairPickups(x, y, z);
   return 1;
}



Re: Repair PickupID - Jefff - 08.07.2018

Quote:
Originally Posted by Jefff
Посмотреть сообщение
you need set all ARepairPickups[i][PickupID] to -1 before loading pickups
In OnGameModeInit
pawn Код:
for(new i = 0; i != sizeof(ARepairPickups); i++)
    ARepairPickups[i][PickupID] = -1;



Re: Repair PickupID - DerickClark - 08.07.2018

Quote:
Originally Posted by Jefff
Посмотреть сообщение
In OnGameModeInit
pawn Код:
for(new i = 0; i != sizeof(ARepairPickups); i++)
    ARepairPickups[i][PickupID] = -1;
Thank you it worked

Thanks you so much Jefff.