06.09.2015, 23:22
I've been toying around with something and I am trying to learn how to use objects.
This is a simple command, it allows you to get, drop and pickup a chair. It's got no purpose, I am simply using it to learn.
I know that to pick up the chair you will have to check the player is near the object and then destroy it, which requires an objectid. How can I assign an id to the object?
This is the command...
Is it something like this?
This is a simple command, it allows you to get, drop and pickup a chair. It's got no purpose, I am simply using it to learn.
I know that to pick up the chair you will have to check the player is near the object and then destroy it, which requires an objectid. How can I assign an id to the object?
This is the command...
PHP код:
CMD:chair(playerid, params[])
{
static
type[24];
new
Float:x,
Float:y,
Float:z,
Float:a;
GetPlayerPos(playerid, x, y, z);
if (sscanf(params, "s[24]", type))
{
SendSyntaxMessage(playerid, "/chair [option]");
SendClientMessage(playerid, COLOR_YELLOW, "[OPTIONS]:{FFFFFF} get, drop, pickup");
return 1;
}
if (!strcmp(type, "get", true))
{
if (GetPVarInt(playerid, "pCarryingChair") == 1)
return SendErrorMessage(playerid, "You are already carrying a chair.");
for (new i = 0; i != MAX_VEHICLES; i ++)
if (IsPlayerNearBoot(playerid, i)
{
SetPlayerAttachedObject(playerid, 1, 1765, 1, -1.106504, 1.504988, 0.031584, 0.000000, 89.566635, 0.000000);
SetPVarInt(playerid, "pCarryingChair", 1);
}
}
if (!strcmp(type, "drop", true))
{
if (GetPVarInt(playerid, "pCarryingChair") == 0)
return SendErrorMessage(playerid, "You are not carrying a chair.");
GetPlayerFacingAngle(playerid, a);
CreateObject(1765, x, y z - 1.0, 0.0, 0.0, a, 50.0);
RemovePlayerAttachedObject(playerid, 1);
SetPVarInt(playerid, "pCarryingChair", 0);
}
if (!strcmp(type, "pickup", true))
{
if (GetPVarInt(playerid, "pCarryingChair) == 1)
return SendErrorMessage(playerid, "You are already carrying a chair.");
}
return 1;
}
PHP код:
new chair;
chair = CreateObject(playerid, 1765, x, y, z, 0.0, 0.0, 0.0);