Carry problem -
cnoopers - 27.01.2015
Hi.
It works only for leatest created object. Why?
Код:
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
if(newkeys == KEY_ANALOG_LEFT)
{
if(!carry)
{
new Float:x, Float:y, Float:z;
GetObjectPos(crate, x, y, z);
if(IsPlayerInRangeOfPoint(playerid, 1.5, x, y, z))
{
ApplyAnimation(playerid, "CARRY", "liftup", 4.1, 0, 1, 1, 0, 0, 1);
SetPlayerSpecialAction(playerid, SPECIAL_ACTION_CARRY);
DestroyObject(crate);
SetPlayerAttachedObject(playerid,0,2358,5,0.091000,0.125999,0.180000,-76.000015,0.000000,100.000000);
carry = true;
}
}else if(carry)
{
ApplyAnimation(playerid, "CARRY", "putdwn", 4.1, 0, 1, 1, 0, 0, 1);
SetPlayerSpecialAction(playerid, SPECIAL_ACTION_NONE);
RemovePlayerAttachedObject(playerid, 0);
new Float:x, Float:y, Float:z, Float:angle;
GetPointInAngleOfPlayer(playerid, x, y, z, 0.8, 0.0);
GetPlayerFacingAngle(playerid, angle);
crate = CreateObject(2358, x, y, z-0.85, 0.0, 0.0, angle);
carry = false;
}
}
return 1;
}
Re: Carry problem -
Jefff - 27.01.2015
Its only for one player you need replace
pawn Код:
new crate;
to
new crate[MAX_PLAYERS];
and next
crate[playerid] = CreateObject(2358, x, y, z-0.85, 0.0, 0.0, angle);
Re: Carry problem -
cnoopers - 27.01.2015
Okay but still that problem. Works only latest created crate.
Re: Carry problem -
Jefff - 27.01.2015
pawn Код:
new crate[MAX_PLAYERS] = {INVALID_OBJECT_ID, ...};
Disconnect
pawn Код:
if(crate[playerid] != INVALID_OBJECT_ID)
DestroyObject(crate[playerid]);
crate[playerid] = INVALID_OBJECT_ID;
pawn Код:
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
if(newkeys & KEY_ANALOG_LEFT)
{
if(crate[playerid] != INVALID_OBJECT_ID)
{
new Float:x, Float:y, Float:z;
GetObjectPos(crate[playerid], x, y, z);
if(IsPlayerInRangeOfPoint(playerid, 1.5, x, y, z))
{
ApplyAnimation(playerid, "CARRY", "liftup", 4.1, 0, 1, 1, 0, 0, 1);
SetPlayerSpecialAction(playerid, SPECIAL_ACTION_CARRY);
DestroyObject(crate[playerid]);
SetPlayerAttachedObject(playerid,0,2358,5,0.091000,0.125999,0.180000,-76.000015,0.000000,100.000000);
crate[playerid] = INVALID_OBJECT_ID;
}
}
else
{
ApplyAnimation(playerid, "CARRY", "putdwn", 4.1, 0, 1, 1, 0, 0, 1);
SetPlayerSpecialAction(playerid, SPECIAL_ACTION_NONE);
RemovePlayerAttachedObject(playerid, 0);
new Float:x, Float:y, Float:z, Float:angle;
GetPointInAngleOfPlayer(playerid, x, y, z, 0.8, 0.0);
GetPlayerFacingAngle(playerid, angle);
crate[playerid] = CreateObject(2358, x, y, z-0.85, 0.0, 0.0, angle);
}
return 0;
}
return 1;
}
Re: Carry problem -
cnoopers - 28.01.2015
Still
This is all what i got:
Код:
#include <a_samp>
#include <fixes>
#include <zcmd>
new crate[MAX_PLAYERS] = {INVALID_OBJECT_ID, ...};
new bool:carry[MAX_PLAYERS];
public OnPlayerConnect(playerid)
{
carry[playerid] = false;
return 1;
}
public OnPlayerDisconnect(playerid)
{
if(crate[playerid] != INVALID_OBJECT_ID)
DestroyObject(crate[playerid]);
crate[playerid] = INVALID_OBJECT_ID;
return 1;
}
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
if(newkeys & KEY_ANALOG_LEFT)
{
if(crate[playerid] != INVALID_OBJECT_ID)
{
new Float:x, Float:y, Float:z;
GetObjectPos(crate[playerid], x, y, z);
if(IsPlayerInRangeOfPoint(playerid, 1.5, x, y, z))
{
ApplyAnimation(playerid, "CARRY", "liftup", 4.1, 0, 1, 1, 0, 0, 1);
SetPlayerSpecialAction(playerid, SPECIAL_ACTION_CARRY);
DestroyObject(crate[playerid]);
SetPlayerAttachedObject(playerid,0,2358,5,0.091000,0.125999,0.180000,-76.000015,0.000000,100.000000);
crate[playerid] = INVALID_OBJECT_ID;
}
}
else
{
ApplyAnimation(playerid, "CARRY", "putdwn", 4.1, 0, 1, 1, 0, 0, 1);
SetPlayerSpecialAction(playerid, SPECIAL_ACTION_NONE);
RemovePlayerAttachedObject(playerid, 0);
new Float:x, Float:y, Float:z, Float:angle;
GetPointInAngleOfPlayer(playerid, x, y, z, 0.8, 0.0);
GetPlayerFacingAngle(playerid, angle);
crate[playerid] = CreateObject(2358, x, y, z-0.85, 0.0, 0.0, angle);
}
return 0;
}
return 1;
}
CMD:crate(playerid, params[])
{
new Float:x, Float:y, Float:z;
GetPlayerPos(playerid, x, y ,z);
crate[playerid] = CreateObject(2358, x, y, z, 0.0, 0.0, 0.0);
return 1;
}
stock GetPointInAngleOfPlayer(playerid, &Float:x, &Float:y, &Float:z, Float:distance, Float:angle)
{
new Float:current_angle;
GetPlayerPos(playerid, x, y, z);
GetPlayerFacingAngle(playerid, current_angle);
if( IsPlayerInAnyVehicle(playerid) )
{
GetVehicleZAngle(GetPlayerVehicleID(playerid), current_angle);
}
new Float:a = current_angle + angle;
x += (distance * floatsin(-a, degrees));
y += (distance * floatcos(-a, degrees));
}
Re: Carry problem -
cnoopers - 28.01.2015
Anyone? REP++++
Re: Carry problem -
cnoopers - 28.01.2015
refr
Re: Carry problem -
Jefff - 29.01.2015
How it should work step by step
Re: Carry problem -
cnoopers - 29.01.2015
Press NUM4 to carry crate. Command crate is only for test. After create next crate previous doesn't works but everyone should work.