Skip to content

Commit 5083889

Browse files
authored
Merge pull request #101 from NexiusTailer/develop
UsePlayerPedAnims, SA-MP to MTA skin aliases, other fixes
2 parents c548ea1 + 6cd6c55 commit 5083889

File tree

13 files changed

+435
-76
lines changed

13 files changed

+435
-76
lines changed

README.md

Lines changed: 17 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -296,7 +296,7 @@ introduces. To use them, `#include <a_amx>` in Pawno.
296296
[clothes page]: https://wiki.multitheftauto.com/wiki/CJ_Clothes
297297

298298
```pawn
299-
native AddPlayerClothes ( playerid, type, index );
299+
native AddPlayerClothes(playerid, type, index);
300300
```
301301

302302
Applies the specified clothing to a player. See the [clothes page] for a
@@ -306,7 +306,7 @@ visible effect on players with the CJ skin.
306306
### GetPlayerClothes
307307

308308
```pawn
309-
native GetPlayerClothes ( playerid, type );
309+
native GetPlayerClothes(playerid, type);
310310
```
311311

312312
Returns the clothes index of the specified type which the player is
@@ -317,7 +317,7 @@ relevant for players with the CJ skin.
317317
### RemovePlayerClothes
318318

319319
```pawn
320-
native RemovePlayerClothes ( playerid, type );
320+
native RemovePlayerClothes(playerid, type);
321321
```
322322

323323
Removes the specified clothing from a player. See the [clothes page] for a
@@ -327,15 +327,15 @@ on players with the CJ skin.
327327
### ShowPlayerMarker
328328

329329
```pawn
330-
native ShowPlayerMarker ( playerid, show );
330+
native ShowPlayerMarker(playerid, mode);
331331
```
332332

333333
Shows or hides the blip of one specific player.
334334

335335
### SetVehicleModel
336336

337337
```pawn
338-
native SetVehicleModel ( vehicleid, model )
338+
native SetVehicleModel(vehicleid, model);
339339
```
340340

341341
Changes the model of a vehicle; more practical than destroying and
@@ -344,7 +344,7 @@ recreating it.
344344
### lua
345345

346346
```pawn
347-
native lua ( const fnName[], {Float,_}:... );
347+
native lua(const fnName[], {Float,_}:...);
348348
```
349349

350350
Calls a Lua function. The function must be defined in a .lua file in the
@@ -361,7 +361,7 @@ new playerid = lua("luaTestfn1", 1.3, "Test string");
361361
### amxRegisterPawnPrototypes
362362

363363
```pawn
364-
native amxRegisterPawnPrototypes ( const prototype[][] );
364+
native amxRegisterPawnPrototypes(const prototype[][]);
365365
```
366366

367367
Registers prototypes for public functions that can be subsequently
@@ -385,15 +385,15 @@ amxRegisterPawnPrototypes(prototypes);
385385
### amxVersion
386386

387387
```pawn
388-
native amxVersion ( &Float:ver );
388+
native amxVersion(&Float:ver);
389389
```
390390

391391
Retrieves the *amx* version as a floating point number, e.g. `1.3`.
392392

393393
### amxVersionString
394394

395395
```pawn
396-
native amxVersionString ( buffer[], size );
396+
native amxVersionString(buffer[], size);
397397
```
398398

399399
Retrieves the complete *amx* version string.
@@ -405,7 +405,7 @@ A number of new Lua functions were also introduced.
405405
### pawn
406406

407407
```lua
408-
variant pawn ( string fnName, ... )
408+
variant pawn(string fnName, ...)
409409
```
410410

411411
Calls a Pawn function. The function must be public, must be defined in
@@ -422,7 +422,7 @@ local player = pawn('pawnTestfn1', 0.5, 'Test string')
422422
### amxIsPluginLoaded
423423

424424
```lua
425-
bool amxIsPluginLoaded ( string pluginName )
425+
bool amxIsPluginLoaded(string pluginName)
426426
```
427427

428428
Checks if a specific SA-MP server plugin is currently loaded. pluginName
@@ -431,7 +431,7 @@ is the name of the plugin without a file extension.
431431
### amxRegisterLuaPrototypes
432432

433433
```lua
434-
bool amxRegisterLuaPrototypes ( table prototypes )
434+
bool amxRegisterLuaPrototypes(table prototypes)
435435
```
436436

437437
Registers prototypes of Lua functions that can subsequently be called
@@ -453,15 +453,15 @@ amxRegisterLuaPrototypes(
453453
### amxVersion
454454

455455
```lua
456-
float amxVersion ( )
456+
float amxVersion()
457457
```
458458

459459
Returns the *amx* version as a floating point number, for example `1.3`.
460460

461461
### amxVersionString
462462

463463
```lua
464-
string amxVersionString ( )
464+
string amxVersionString()
465465
```
466466

467467
Returns the complete *amx* version string.
@@ -474,7 +474,7 @@ unloaded.
474474
### onAMXStart
475475

476476
```lua
477-
onAMXStart ( resource res, string amxName )
477+
onAMXStart(resource res, string amxName)
478478
```
479479

480480
Triggered when an .amx file has just finished loading and initializing.
@@ -489,7 +489,7 @@ registered their functions yet.
489489
### onAMXStop
490490

491491
```lua
492-
onAMXStop ( resource res, string amxName )
492+
onAMXStop(resource res, string amxName)
493493
```
494494

495495
Triggered when an .amx file was unloaded. The source of this event is
@@ -680,8 +680,7 @@ addressed in later versions of *amx* and Multi Theft Auto.
680680
EnableStuntBonusForAll, EnableStuntBonusForPlayer, EnableTirePopping
681681
(tire popping is always on), PlayerPlaySound, SendDeathMessage (use
682682
the "killmessages" resource on your server instead for graphical
683-
death messages), SetNameTagDrawDistance, TextDrawSetProportional,
684-
UsePlayerPedAnims.
683+
death messages), SetNameTagDrawDistance, TextDrawSetProportional.
685684

686685
## Credits
687686

amx-test/file.txt

Lines changed: 0 additions & 1 deletion
This file was deleted.

amx-test/pawno/include/a_amx.inc

Lines changed: 27 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,8 @@ native GetInteriorSoundsEnabled();
4343
native SetInteriorSoundsEnabled(bool:enable);
4444
native IsGarageOpen(garageid);
4545
native SetGarageOpen(garageid, bool:open);
46-
native IsGlitchEnabled(name[]);
47-
native SetGlitchEnabled(name[], bool:enable);
46+
native IsGlitchEnabled(const name[]);
47+
native SetGlitchEnabled(const name[], bool:enable);
4848
native Float:GetAircraftMaxVelocity();
4949
native SetAircraftMaxVelocity(Float:velocity);
5050
native Float:GetAircraftMaxHeight();
@@ -69,7 +69,7 @@ native GetPickupWeapon(pickupid);
6969
native GetPickupAmmo(pickupid);
7070
7171
// Native Markers
72-
native CreateMarker(Float:X, Float:Y, Float:Z, type[], Float:size, red, green, blue, alpha);
72+
native CreateMarker(Float:X, Float:Y, Float:Z, const type[], Float:size, red, green, blue, alpha);
7373
native DestroyMarker(markerid);
7474
native GetMarkerColor(markerid, colorid); // Color IDs: 0 = Red, 1 = Green, 2 = Blue, 3 = Alpha
7575
native GetMarkerIcon(markerid); // 0 = No icon, 1 = Arrow, 2 = Race finish
@@ -86,10 +86,10 @@ native IsBotInMarker(markerid, botid);
8686
native IsVehicleInMarker(markerid, vehicleid);
8787
8888
// Rules
89-
native IsValidServerRule(name[]);
90-
native GetServerRule(name[], buf[], bufsize = sizeof(buf));
91-
native SetServerRule(name[], value[]);
92-
native RemoveServerRule(name[]);
89+
native IsValidServerRule(const name[]);
90+
native GetServerRule(const name[], buf[], bufsize = sizeof(buf));
91+
native SetServerRule(const name[], const value[]);
92+
native RemoveServerRule(const name[]);
9393
9494
// Objects
9595
native IsObjectBreakable(objectid);
@@ -122,12 +122,13 @@ native SetPlayerCanBeKnockedOffBike(playerid, bool:knockOff);
122122
native GetPlayerWeaponSlot(playerid);
123123
native SetPlayerWeaponSlot(playerid, slotid);
124124
native GetPlayerAmmoInClip(playerid);
125+
native GetPlayerIdleTime(playerid);
125126
native IsPlayerHeadless(playerid);
126127
native SetPlayerHeadless(playerid, bool:headless);
127128
native GetPlayerBlurLevel(playerid);
128129
native SetPlayerBlurLevel(playerid, level);
129130
native FadePlayerCamera(playerid, bool:fadeIn, Float:timeToFade = 1.0, red = 0, green = 0, blue = 0);
130-
native SetPlayerControlState(playerid, control[], bool:controlState);
131+
native SetPlayerControlState(playerid, const control[], bool:controlState);
131132
native IsPlayerCursorShowing(playerid);
132133
native ShowPlayerCursor(playerid, bool:show, bool:controls);
133134
native GetPlayerAlpha(playerid);
@@ -168,14 +169,14 @@ native GetTrainDirection(vehicleid);
168169
native SetTrainDirection(vehicleid, bool:clockwise);
169170
native GetTrainSpeed(vehicleid, &Float:speed);
170171
native SetTrainSpeed(vehicleid, Float:speed);
171-
native GetVehicleDriver(vehicleid);
172+
native GetVehicleOccupant(vehicleid, seatid);
172173
native GetVehicleNumberPlate(vehicleid, plate[], len = sizeof(plate));
173174
native GetVehicleColor(vehicleid, &color1, &color2);
174175
native GetVehiclePaintjob(vehicleid);
175176
native GetVehicleInterior(vehicleid);
176177
177178
// Bots
178-
native CreateBot(modelid, Float:x, Float:y, Float:z, name[] = "Bot");
179+
native CreateBot(modelid, Float:x, Float:y, Float:z, const name[] = "Bot");
179180
native DestroyBot(botid);
180181
native AddBotClothes(botid, type, index);
181182
native GetBotClothes(botid, type);
@@ -218,7 +219,7 @@ native GetBotVehicleID(botid);
218219
native GetBotVehicleSeat(botid);
219220
native IsBotInVehicle(botid, vehicleid);
220221
native IsBotInAnyVehicle(botid);
221-
native SetBotControlState(botid, control[], bool:controlState);
222+
native SetBotControlState(botid, const control[], bool:controlState);
222223
native SetBotAimTarget(botid, Float:X, Float:Y, Float:Z);
223224
native GetBotDoingDriveBy(botid);
224225
native SetBotDoingDriveBy(botid, bool:driveBy);
@@ -239,22 +240,22 @@ native GetBotAlpha(botid);
239240
native SetBotAlpha(botid, alpha);
240241
241242
// Scoreboard
242-
native AddScoreBoardColumn(column[]);
243-
native SetPlayerScoreBoardData(playerid, column[], data[]);
244-
native RemoveScoreBoardColumn(column[]);
243+
native AddScoreBoardColumn(const column[]);
244+
native SetPlayerScoreBoardData(playerid, const column[], const data[]);
245+
native RemoveScoreBoardColumn(const column[]);
245246
246247
// Player Data
247-
native SetPlayerIntData(playerid, key[], value);
248-
native GetPlayerIntData(playerid, key[]);
249-
native SetPlayerFloatData(playerid, key[], Float:value);
250-
native Float:GetPlayerFloatData(playerid, key[]);
251-
native SetPlayerBoolData(playerid, key[], bool:value);
252-
native GetPlayerBoolData(playerid, key[]);
253-
native SetPlayerStringData(playerid, key[], value[]);
254-
native GetPlayerStringData(playerid, key[], buf[], bufsize = sizeof(buf));
255-
native ResetPlayerData(playerid, key[]);
248+
native SetPlayerIntData(playerid, const key[], value);
249+
native GetPlayerIntData(playerid, const key[]);
250+
native SetPlayerFloatData(playerid, const key[], Float:value);
251+
native Float:GetPlayerFloatData(playerid, const key[]);
252+
native SetPlayerBoolData(playerid, const key[], bool:value);
253+
native GetPlayerBoolData(playerid, const key[]);
254+
native SetPlayerStringData(playerid, const key[], const value[]);
255+
native GetPlayerStringData(playerid, const key[], buf[], bufsize = sizeof(buf));
256+
native ResetPlayerData(playerid, const key[]);
256257
257258
// Misc
258-
native AddEventHandler(event[], func[]);
259-
native RemoveEventHandler(func[]);
260-
native IsPluginLoaded(plugin[]);
259+
native AddEventHandler(const event[], const func[]);
260+
native RemoveEventHandler(const func[]);
261+
native IsPluginLoaded(const plugin[]);

amx/meta.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
<script src="server/defines.lua" type="server" />
66
<script src="shared/anim_define.lua" type="shared" />
7+
<script src="shared/ped_anim.lua" type="shared" />
78
<script src="shared/vehicle_info.lua" type="shared" />
89
<script src="server/util.lua" type="server" />
910
<script src="server/_triggerqueue.lua" type="server" />

amx/server/amx.lua

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ function initGameModeGlobals()
2525
g_PlayerMarkerRadius = false
2626
g_ShowZoneNames = true
2727
g_GlobalChatRadius = false
28+
g_UseCJWalk = false
2829
end
2930

3031
addEventHandler('onResourceStart', resourceRoot,
@@ -189,7 +190,7 @@ function unloadAMX(amx, notifyClient)
189190
if amx.type == 'gamemode' then
190191
procCallInternal(amx, 'OnGameModeExit')
191192
fadeCamera(root, false, 0)
192-
ShowPlayerMarkers(amx, false)
193+
ShowPlayerMarkers(amx, 0)
193194
destroyGlobalElements()
194195

195196
if notifyClient == nil or notifyClient == true then

amx/server/defines.lua

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,34 @@ g_PoliceVehicles = {
135135
[601] = true
136136
}
137137

138+
g_SkinReplace = {
139+
[3] = 303, -- andre
140+
[4] = 310, -- bbthin
141+
[6] = 302, -- emmet
142+
[8] = 309, -- janitor
143+
[42] = 305, -- jethro
144+
[65] = 304, -- kendl
145+
[74] = 0, -- unused
146+
[86] = 301, -- ryder3
147+
[119] = 308, -- sindaco
148+
[149] = 311, -- smokev
149+
[208] = 42, -- suzie
150+
[273] = 307, -- tbone
151+
[289] = 306, -- zero
152+
[300] = 280, -- lapd1
153+
[301] = 281, -- sfpd1
154+
[302] = 282, -- lvpd1
155+
[303] = 280, -- lapd1
156+
[304] = 280, -- lapd1
157+
[305] = 282, -- lvpd1
158+
[306] = 211, -- wfyclot
159+
[307] = 11, -- vbfycrp
160+
[308] = 211, -- wfyclot
161+
[309] = 211, -- wfyclot
162+
[310] = 283, -- csher
163+
[311] = 288 -- dsher
164+
}
165+
138166
-- Left is SA-MP, right is MTA
139167
g_BoneMapping = setmetatable({
140168
[2] = 1, -- Head

amx/server/events.lua

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -283,6 +283,14 @@ addEventHandler('onPlayerSpawn', root,
283283
procCallOnAll('OnPlayerSpawn', playerID)
284284
setPlayerState(source, PLAYER_STATE_SPAWNED)
285285

286+
-- wanna see CJ in a white singlet?
287+
addPedClothes(source, 'vest', 'vest', 0)
288+
289+
if not g_UseCJWalk then
290+
local skin = getElementModel(source)
291+
setPedWalkingStyle(source, WalkingStyle[skin] or 0)
292+
end
293+
286294
if g_Players[playerID].updatetimer then
287295
killTimer(g_Players[playerID].updatetimer)
288296
end

amx/server/natives/a_actors.lua

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
function CreateActor(amx, model, x, y, z, rotation)
2-
local actor = createPed(model, x, y, z, rotation, false)
2+
local actor = createPed(g_SkinReplace[model] or model, x, y, z, rotation, false)
3+
addPedClothes(actor, 'vest', 'vest', 0)
34
setElementData(actor, 'ActorPed', true)
45
setElementData(actor, 'Invulnerable', true)
56
return addElem(g_Actors, actor)

amx/server/natives/a_mta.lua

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,12 @@ function GetPlayerWalkingStyle(amx, player)
7777
end
7878

7979
function SetPlayerWalkingStyle(amx, player, style)
80+
-- if style is MOVE_DEFAULT and CJ walk isn't enabled
81+
if style == 0 and not g_UseCJWalk then
82+
-- return walking style back to default for this skin
83+
local skin = getElementModel(player)
84+
return setPedWalkingStyle(player, WalkingStyle[skin] or 0)
85+
end
8086
return setPedWalkingStyle(player, style)
8187
end
8288

@@ -118,6 +124,10 @@ function GetPlayerAmmoInClip(amx, player)
118124
return getPedAmmoInClip(player)
119125
end
120126

127+
function GetPlayerIdleTime(amx, player)
128+
return getPlayerIdleTime(player)
129+
end
130+
121131
function IsPlayerHeadless(amx, player)
122132
return isPedHeadless(player)
123133
end
@@ -169,7 +179,8 @@ end
169179
-- Bots
170180

171181
function CreateBot(amx, model, x, y, z, name)
172-
local bot = createPed(model, x, y, z)
182+
local bot = createPed(g_SkinReplace[model] or model, x, y, z)
183+
addPedClothes(bot, 'vest', 'vest', 0)
173184
setElementData(bot, 'ShowNameTag', true)
174185
setElementData(bot, 'BotName', name)
175186
local botId = addElem(g_Bots, bot)
@@ -566,8 +577,8 @@ function SetTrainSpeed(amx, train, speed)
566577
return setTrainSpeed(train, speed)
567578
end
568579

569-
function GetVehicleDriver(amx, vehicle)
570-
local player = getVehicleOccupant(vehicle)
580+
function GetVehicleOccupant(amx, vehicle, seat)
581+
local player = getVehicleOccupant(vehicle, seat)
571582
if not player then
572583
return INVALID_PLAYER_ID
573584
end

0 commit comments

Comments
 (0)