I need help with my loot system.
#1

So, what I've got so far is a loot system that adds gas cans when you pickup the gas can objects.
And when a player dies, it drops a gas can, or two, or three, or four, depending on how many they have.

The problem is, I have to check through each playerid and each slot etc. etc.

The way my system works now I would have to type this all in 500 times for each item that was dropped and yeah... it would work, but it would kill my fingers. Surely there's an easier way?

Код:
new
	gascan[MAX_PLAYERS],
	gasdrop[MAX_PLAYERS][4]
;

public OnPlayerDeath(playerid, killerid, reason)
{
	GetPlayerPos(playerid, PosX[playerid], PosY[playerid], PosZ[playerid]);
	if(gascan[playerid] == 1)
	{
	gasdrop[playerid][0] = CreateDynamicObject(1650, PosX[playerid], PosY[playerid], PosZ[playerid] - 0.7, 0.0, 0.0, 0.0);
	GetObjectPos(gasdrop[playerid][0], dX[playerid][0], dY[playerid][0], dZ[playerid][0]);
	}
	if(gascan[playerid] == 2)
	{
	gasdrop[playerid][0] = CreateDynamicObject(1650, PosX[playerid], PosY[playerid], PosZ[playerid] - 0.7, 0.0, 0.0, 0.0);
	GetObjectPos(gasdrop[playerid][0], dX[playerid][0], dY[playerid][0], dZ[playerid][0]);
	gasdrop[playerid][1] = CreateDynamicObject(1650, PosX[playerid], PosY[playerid], PosZ[playerid] - 0.7, 0.0, 0.0, 0.0);
    GetObjectPos(gasdrop[playerid][1], dX[playerid][1], dY[playerid][1], dZ[playerid][1]);
	}
	if(gascan[playerid] == 3)
	{
	gasdrop[playerid][0] = CreateDynamicObject(1650, PosX[playerid], PosY[playerid], PosZ[playerid] - 0.7, 0.0, 0.0, 0.0);
	GetObjectPos(gasdrop[playerid][0], dX[playerid][0], dY[playerid][0], dZ[playerid][0]);
	gasdrop[playerid][1] = CreateDynamicObject(1650, PosX[playerid], PosY[playerid], PosZ[playerid] - 0.7, 0.0, 0.0, 0.0);
    GetObjectPos(gasdrop[playerid][1], dX[playerid][1], dY[playerid][1], dZ[playerid][1]);
	gasdrop[playerid][2] = CreateDynamicObject(1650, PosX[playerid], PosY[playerid], PosZ[playerid] - 0.7, 0.0, 0.0, 0.0);
    GetObjectPos(gasdrop[playerid][2], dX[playerid][2], dY[playerid][2], dZ[playerid][2]);
	}
	if(gascan[playerid] == 4)
	{
	gasdrop[playerid][0] = CreateDynamicObject(1650, PosX[playerid], PosY[playerid], PosZ[playerid] - 0.7, 0.0, 0.0, 0.0);
	GetObjectPos(gasdrop[playerid][0], dX[playerid][0], dY[playerid][0], dZ[playerid][0]);
	gasdrop[playerid][1] = CreateDynamicObject(1650, PosX[playerid], PosY[playerid], PosZ[playerid] - 0.7, 0.0, 0.0, 0.0);
    GetObjectPos(gasdrop[playerid][1], dX[playerid][1], dY[playerid][1], dZ[playerid][1]);
	gasdrop[playerid][2] = CreateDynamicObject(1650, PosX[playerid], PosY[playerid], PosZ[playerid] - 0.7, 0.0, 0.0, 0.0);
    GetObjectPos(gasdrop[playerid][2], dX[playerid][2], dY[playerid][2], dZ[playerid][2]);
	gasdrop[playerid][3] = CreateDynamicObject(1650, PosX[playerid], PosY[playerid], PosZ[playerid] - 0.7, 0.0, 0.0, 0.0);
    GetObjectPos(gasdrop[playerid][3], dX[playerid][3], dY[playerid][3], dZ[playerid][3]);
	}
	}
	return 1;
}

	if (PRESSED( KEY_CROUCH ))
    {
        if(IsValidDynamicObject(gasdrop[0][0]) && IsPlayerInRangeOfPoint(playerid,1.0,dX[0][0],dY[0][0],dZ[0][0]))
        {
			gascan[playerid] = gascan[playerid] +1;
            SendClientMessage(playerid, -1, "* 1 full gas can has been added to your inventory");
            DestroyDynamicObject(gasdrop[0][0]);
        }
        if(IsValidDynamicObject(gasdrop[0][1]) && IsPlayerInRangeOfPoint(playerid,1.0,dX[0][1],dY[0][1],dZ[0][1]))
        {
			gascan[playerid] = gascan[playerid] +1;
            SendClientMessage(playerid, -1, "* 1 full gas can has been added to your inventory");
            DestroyDynamicObject(gasdrop[0][1]);
        }
    }
	return 1;
}
Reply


Messages In This Thread
I need help with my loot system. - by Unfriendly - 08.02.2014, 23:43
Re: I need help with my loot system. - by CuervO - 09.02.2014, 03:26
Re: I need help with my loot system. - by Unfriendly - 10.02.2014, 14:45

Forum Jump:


Users browsing this thread: 1 Guest(s)