-
Notifications
You must be signed in to change notification settings - Fork 118
/
Copy pathattachments.inc
163 lines (155 loc) · 6.1 KB
/
attachments.inc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
#if defined attachments_included
#endinput
#endif
#define attachments_included
#if !defined KEY_AIM
#define KEY_AIM 128
#endif
enum E_PLAYER_ATTACHMENT
{
bool:E_PLAYER_ATTACHMENT_USED,
E_PLAYER_ATTACHMENT_MODEL,
E_PLAYER_ATTACHMENT_BONE,
Float:E_PLAYER_ATTACHMENT_X,
Float:E_PLAYER_ATTACHMENT_Y,
Float:E_PLAYER_ATTACHMENT_Z,
Float:E_PLAYER_ATTACHMENT_RX,
Float:E_PLAYER_ATTACHMENT_RY,
Float:E_PLAYER_ATTACHMENT_RZ,
Float:E_PLAYER_ATTACHMENT_SX,
Float:E_PLAYER_ATTACHMENT_SY,
Float:E_PLAYER_ATTACHMENT_SZ,
E_PLAYER_ATTACHMENT_COLOR1,
E_PLAYER_ATTACHMENT_COLOR2
};
static playerAttachment[MAX_PLAYERS][MAX_PLAYER_ATTACHED_OBJECTS][E_PLAYER_ATTACHMENT];
public OnPlayerConnect(playerid)
{
for (new i; i < MAX_PLAYER_ATTACHED_OBJECTS; i++)
{
playerAttachment[playerid][i][E_PLAYER_ATTACHMENT_USED] = false;
playerAttachment[playerid][i][E_PLAYER_ATTACHMENT_MODEL] = 0;
playerAttachment[playerid][i][E_PLAYER_ATTACHMENT_BONE] = 0;
playerAttachment[playerid][i][E_PLAYER_ATTACHMENT_X] = 0.0;
playerAttachment[playerid][i][E_PLAYER_ATTACHMENT_Y] = 0.0;
playerAttachment[playerid][i][E_PLAYER_ATTACHMENT_Z] = 0.0;
playerAttachment[playerid][i][E_PLAYER_ATTACHMENT_RX] = 0.0;
playerAttachment[playerid][i][E_PLAYER_ATTACHMENT_RY] = 0.0;
playerAttachment[playerid][i][E_PLAYER_ATTACHMENT_RZ] = 0.0;
playerAttachment[playerid][i][E_PLAYER_ATTACHMENT_SX] = 1.0;
playerAttachment[playerid][i][E_PLAYER_ATTACHMENT_SY] = 1.0;
playerAttachment[playerid][i][E_PLAYER_ATTACHMENT_SZ] = 1.0;
playerAttachment[playerid][i][E_PLAYER_ATTACHMENT_COLOR1] = 0;
playerAttachment[playerid][i][E_PLAYER_ATTACHMENT_COLOR2] = 0;
}
#if defined ATT_OnPlayerConnect
return ATT_OnPlayerConnect(playerid);
#else
return 1;
#endif
}
#if defined _ALS_OnPlayerConnect
#undef OnPlayerConnect
#else
#define _ALS_OnPlayerConnect
#endif
#define OnPlayerConnect ATT_OnPlayerConnect
#if defined ATT_OnPlayerConnect
forward ATT_OnPlayerConnect(playerid);
#endif
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
if (GetPlayerState(playerid) == PLAYER_STATE_ONFOOT)
{
if ((newkeys & KEY_AIM) == KEY_AIM)
{
switch (GetPlayerWeapon(playerid))
{
case WEAPON_SNIPER, WEAPON_ROCKETLAUNCHER, WEAPON_HEATSEEKER, WEAPON_CAMERA:
{
for (new i; i < MAX_PLAYER_ATTACHED_OBJECTS; i++)
{
if (IsPlayerAttachedObjectSlotUsed(playerid, i))
{
RemovePlayerAttachedObject(playerid, i);
}
}
}
}
}
else if ((newkeys & KEY_AIM) != KEY_AIM && (oldkeys & KEY_AIM) == KEY_AIM)
{
for (new i; i < MAX_PLAYER_ATTACHED_OBJECTS; i++)
{
if (!IsPlayerAttachedObjectSlotUsed(playerid, i) && playerAttachment[playerid][i][E_PLAYER_ATTACHMENT_USED])
{
SetPlayerAttachedObject(playerid, i,
playerAttachment[playerid][i][E_PLAYER_ATTACHMENT_MODEL],
playerAttachment[playerid][i][E_PLAYER_ATTACHMENT_BONE],
playerAttachment[playerid][i][E_PLAYER_ATTACHMENT_X], playerAttachment[playerid][i][E_PLAYER_ATTACHMENT_Y], playerAttachment[playerid][i][E_PLAYER_ATTACHMENT_Z],
playerAttachment[playerid][i][E_PLAYER_ATTACHMENT_RX], playerAttachment[playerid][i][E_PLAYER_ATTACHMENT_RY], playerAttachment[playerid][i][E_PLAYER_ATTACHMENT_RZ],
playerAttachment[playerid][i][E_PLAYER_ATTACHMENT_SX], playerAttachment[playerid][i][E_PLAYER_ATTACHMENT_SY], playerAttachment[playerid][i][E_PLAYER_ATTACHMENT_SZ],
playerAttachment[playerid][i][E_PLAYER_ATTACHMENT_COLOR1],
playerAttachment[playerid][i][E_PLAYER_ATTACHMENT_COLOR2]);
}
}
}
}
#if defined ATT_OnPlayerKeyStateChange
return ATT_OnPlayerKeyStateChange(playerid, newkeys, oldkeys);
#else
return 1;
#endif
}
#if defined _ALS_OnPlayerKeyStateChange
#undef OnPlayerKeyStateChange
#else
#define _ALS_OnPlayerKeyStateChange
#endif
#define OnPlayerKeyStateChange ATT_OnPlayerKeyStateChange
#if defined ATT_OnPlayerKeyStateChange
forward ATT_OnPlayerKeyStateChange(playerid, newkeys, oldkeys);
#endif
stock ATT_SetPlayerAttachedObject(playerid, index, modelid, bone, Float:fOffsetX = 0.0, Float:fOffsetY = 0.0, Float:fOffsetZ = 0.0, Float:fRotX = 0.0, Float:fRotY = 0.0, Float:fRotZ = 0.0, Float:fScaleX = 1.0, Float:fScaleY = 1.0, Float:fScaleZ = 1.0, materialcolor1 = 0, materialcolor2 = 0)
{
new ret = SetPlayerAttachedObject(playerid, index, modelid, bone, fOffsetX, fOffsetY, fOffsetZ, fRotX, fRotY, fRotZ, fScaleX, fScaleY, fScaleZ, materialcolor1, materialcolor2);
if (ret)
{
playerAttachment[playerid][index][E_PLAYER_ATTACHMENT_USED] = true;
playerAttachment[playerid][index][E_PLAYER_ATTACHMENT_MODEL] = modelid;
playerAttachment[playerid][index][E_PLAYER_ATTACHMENT_BONE] = bone;
playerAttachment[playerid][index][E_PLAYER_ATTACHMENT_X] = fOffsetX;
playerAttachment[playerid][index][E_PLAYER_ATTACHMENT_Y] = fOffsetY;
playerAttachment[playerid][index][E_PLAYER_ATTACHMENT_Z] = fOffsetZ;
playerAttachment[playerid][index][E_PLAYER_ATTACHMENT_RX] = fRotX;
playerAttachment[playerid][index][E_PLAYER_ATTACHMENT_RY] = fRotY;
playerAttachment[playerid][index][E_PLAYER_ATTACHMENT_RZ] = fRotZ;
playerAttachment[playerid][index][E_PLAYER_ATTACHMENT_SX] = fScaleX;
playerAttachment[playerid][index][E_PLAYER_ATTACHMENT_SY] = fScaleY;
playerAttachment[playerid][index][E_PLAYER_ATTACHMENT_SZ] = fScaleZ;
playerAttachment[playerid][index][E_PLAYER_ATTACHMENT_COLOR1] = materialcolor1;
playerAttachment[playerid][index][E_PLAYER_ATTACHMENT_COLOR2] = materialcolor2;
}
return ret;
}
#if defined _ALS_SetPlayerAttachedObject
#undef SetPlayerAttachedObject
#else
#define _ALS_SetPlayerAttachedObject
#endif
#define SetPlayerAttachedObject ATT_SetPlayerAttachedObject
stock ATT_RemovePlayerAttachedObject(playerid, index)
{
new ret = RemovePlayerAttachedObject(playerid, index);
if (ret)
{
playerAttachment[playerid][index][E_PLAYER_ATTACHMENT_USED] = false;
}
return ret;
}
#if defined _ALS_RemovePlayerAttachedObject
#undef RemovePlayerAttachedObject
#else
#define _ALS_RemovePlayerAttachedObject
#endif
#define RemovePlayerAttachedObject ATT_RemovePlayerAttachedObject