Skip to content

UsePlayerPedAnims, SA-MP to MTA skin aliases, other fixes #101

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 14 commits into from
May 7, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 17 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@ introduces. To use them, `#include <a_amx>` in Pawno.
[clothes page]: https://wiki.multitheftauto.com/wiki/CJ_Clothes

```pawn
native AddPlayerClothes ( playerid, type, index );
native AddPlayerClothes(playerid, type, index);
```

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

```pawn
native GetPlayerClothes ( playerid, type );
native GetPlayerClothes(playerid, type);
```

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

```pawn
native RemovePlayerClothes ( playerid, type );
native RemovePlayerClothes(playerid, type);
```

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

```pawn
native ShowPlayerMarker ( playerid, show );
native ShowPlayerMarker(playerid, mode);
```

Shows or hides the blip of one specific player.

### SetVehicleModel

```pawn
native SetVehicleModel ( vehicleid, model )
native SetVehicleModel(vehicleid, model);
```

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

```pawn
native lua ( const fnName[], {Float,_}:... );
native lua(const fnName[], {Float,_}:...);
```

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

```pawn
native amxRegisterPawnPrototypes ( const prototype[][] );
native amxRegisterPawnPrototypes(const prototype[][]);
```

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

```pawn
native amxVersion ( &Float:ver );
native amxVersion(&Float:ver);
```

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

### amxVersionString

```pawn
native amxVersionString ( buffer[], size );
native amxVersionString(buffer[], size);
```

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

```lua
variant pawn ( string fnName, ... )
variant pawn(string fnName, ...)
```

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

```lua
bool amxIsPluginLoaded ( string pluginName )
bool amxIsPluginLoaded(string pluginName)
```

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

```lua
bool amxRegisterLuaPrototypes ( table prototypes )
bool amxRegisterLuaPrototypes(table prototypes)
```

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

```lua
float amxVersion ( )
float amxVersion()
```

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

### amxVersionString

```lua
string amxVersionString ( )
string amxVersionString()
```

Returns the complete *amx* version string.
Expand All @@ -474,7 +474,7 @@ unloaded.
### onAMXStart

```lua
onAMXStart ( resource res, string amxName )
onAMXStart(resource res, string amxName)
```

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

```lua
onAMXStop ( resource res, string amxName )
onAMXStop(resource res, string amxName)
```

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

## Credits

Expand Down
1 change: 0 additions & 1 deletion amx-test/file.txt

This file was deleted.

53 changes: 27 additions & 26 deletions amx-test/pawno/include/a_amx.inc
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ native GetInteriorSoundsEnabled();
native SetInteriorSoundsEnabled(bool:enable);
native IsGarageOpen(garageid);
native SetGarageOpen(garageid, bool:open);
native IsGlitchEnabled(name[]);
native SetGlitchEnabled(name[], bool:enable);
native IsGlitchEnabled(const name[]);
native SetGlitchEnabled(const name[], bool:enable);
native Float:GetAircraftMaxVelocity();
native SetAircraftMaxVelocity(Float:velocity);
native Float:GetAircraftMaxHeight();
Expand All @@ -69,7 +69,7 @@ native GetPickupWeapon(pickupid);
native GetPickupAmmo(pickupid);

// Native Markers
native CreateMarker(Float:X, Float:Y, Float:Z, type[], Float:size, red, green, blue, alpha);
native CreateMarker(Float:X, Float:Y, Float:Z, const type[], Float:size, red, green, blue, alpha);
native DestroyMarker(markerid);
native GetMarkerColor(markerid, colorid); // Color IDs: 0 = Red, 1 = Green, 2 = Blue, 3 = Alpha
native GetMarkerIcon(markerid); // 0 = No icon, 1 = Arrow, 2 = Race finish
Expand All @@ -86,10 +86,10 @@ native IsBotInMarker(markerid, botid);
native IsVehicleInMarker(markerid, vehicleid);

// Rules
native IsValidServerRule(name[]);
native GetServerRule(name[], buf[], bufsize = sizeof(buf));
native SetServerRule(name[], value[]);
native RemoveServerRule(name[]);
native IsValidServerRule(const name[]);
native GetServerRule(const name[], buf[], bufsize = sizeof(buf));
native SetServerRule(const name[], const value[]);
native RemoveServerRule(const name[]);

// Objects
native IsObjectBreakable(objectid);
Expand Down Expand Up @@ -122,12 +122,13 @@ native SetPlayerCanBeKnockedOffBike(playerid, bool:knockOff);
native GetPlayerWeaponSlot(playerid);
native SetPlayerWeaponSlot(playerid, slotid);
native GetPlayerAmmoInClip(playerid);
native GetPlayerIdleTime(playerid);
native IsPlayerHeadless(playerid);
native SetPlayerHeadless(playerid, bool:headless);
native GetPlayerBlurLevel(playerid);
native SetPlayerBlurLevel(playerid, level);
native FadePlayerCamera(playerid, bool:fadeIn, Float:timeToFade = 1.0, red = 0, green = 0, blue = 0);
native SetPlayerControlState(playerid, control[], bool:controlState);
native SetPlayerControlState(playerid, const control[], bool:controlState);
native IsPlayerCursorShowing(playerid);
native ShowPlayerCursor(playerid, bool:show, bool:controls);
native GetPlayerAlpha(playerid);
Expand Down Expand Up @@ -168,14 +169,14 @@ native GetTrainDirection(vehicleid);
native SetTrainDirection(vehicleid, bool:clockwise);
native GetTrainSpeed(vehicleid, &Float:speed);
native SetTrainSpeed(vehicleid, Float:speed);
native GetVehicleDriver(vehicleid);
native GetVehicleOccupant(vehicleid, seatid);
native GetVehicleNumberPlate(vehicleid, plate[], len = sizeof(plate));
native GetVehicleColor(vehicleid, &color1, &color2);
native GetVehiclePaintjob(vehicleid);
native GetVehicleInterior(vehicleid);

// Bots
native CreateBot(modelid, Float:x, Float:y, Float:z, name[] = "Bot");
native CreateBot(modelid, Float:x, Float:y, Float:z, const name[] = "Bot");
native DestroyBot(botid);
native AddBotClothes(botid, type, index);
native GetBotClothes(botid, type);
Expand Down Expand Up @@ -218,7 +219,7 @@ native GetBotVehicleID(botid);
native GetBotVehicleSeat(botid);
native IsBotInVehicle(botid, vehicleid);
native IsBotInAnyVehicle(botid);
native SetBotControlState(botid, control[], bool:controlState);
native SetBotControlState(botid, const control[], bool:controlState);
native SetBotAimTarget(botid, Float:X, Float:Y, Float:Z);
native GetBotDoingDriveBy(botid);
native SetBotDoingDriveBy(botid, bool:driveBy);
Expand All @@ -239,22 +240,22 @@ native GetBotAlpha(botid);
native SetBotAlpha(botid, alpha);

// Scoreboard
native AddScoreBoardColumn(column[]);
native SetPlayerScoreBoardData(playerid, column[], data[]);
native RemoveScoreBoardColumn(column[]);
native AddScoreBoardColumn(const column[]);
native SetPlayerScoreBoardData(playerid, const column[], const data[]);
native RemoveScoreBoardColumn(const column[]);

// Player Data
native SetPlayerIntData(playerid, key[], value);
native GetPlayerIntData(playerid, key[]);
native SetPlayerFloatData(playerid, key[], Float:value);
native Float:GetPlayerFloatData(playerid, key[]);
native SetPlayerBoolData(playerid, key[], bool:value);
native GetPlayerBoolData(playerid, key[]);
native SetPlayerStringData(playerid, key[], value[]);
native GetPlayerStringData(playerid, key[], buf[], bufsize = sizeof(buf));
native ResetPlayerData(playerid, key[]);
native SetPlayerIntData(playerid, const key[], value);
native GetPlayerIntData(playerid, const key[]);
native SetPlayerFloatData(playerid, const key[], Float:value);
native Float:GetPlayerFloatData(playerid, const key[]);
native SetPlayerBoolData(playerid, const key[], bool:value);
native GetPlayerBoolData(playerid, const key[]);
native SetPlayerStringData(playerid, const key[], const value[]);
native GetPlayerStringData(playerid, const key[], buf[], bufsize = sizeof(buf));
native ResetPlayerData(playerid, const key[]);

// Misc
native AddEventHandler(event[], func[]);
native RemoveEventHandler(func[]);
native IsPluginLoaded(plugin[]);
native AddEventHandler(const event[], const func[]);
native RemoveEventHandler(const func[]);
native IsPluginLoaded(const plugin[]);
1 change: 1 addition & 0 deletions amx/meta.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

<script src="server/defines.lua" type="server" />
<script src="shared/anim_define.lua" type="shared" />
<script src="shared/ped_anim.lua" type="shared" />
<script src="shared/vehicle_info.lua" type="shared" />
<script src="server/util.lua" type="server" />
<script src="server/_triggerqueue.lua" type="server" />
Expand Down
3 changes: 2 additions & 1 deletion amx/server/amx.lua
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ function initGameModeGlobals()
g_PlayerMarkerRadius = false
g_ShowZoneNames = true
g_GlobalChatRadius = false
g_UseCJWalk = false
end

addEventHandler('onResourceStart', resourceRoot,
Expand Down Expand Up @@ -189,7 +190,7 @@ function unloadAMX(amx, notifyClient)
if amx.type == 'gamemode' then
procCallInternal(amx, 'OnGameModeExit')
fadeCamera(root, false, 0)
ShowPlayerMarkers(amx, false)
ShowPlayerMarkers(amx, 0)
destroyGlobalElements()

if notifyClient == nil or notifyClient == true then
Expand Down
28 changes: 28 additions & 0 deletions amx/server/defines.lua
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,34 @@ g_PoliceVehicles = {
[601] = true
}

g_SkinReplace = {
[3] = 303, -- andre
[4] = 310, -- bbthin
[6] = 302, -- emmet
[8] = 309, -- janitor
[42] = 305, -- jethro
[65] = 304, -- kendl
[74] = 0, -- unused
[86] = 301, -- ryder3
[119] = 308, -- sindaco
[149] = 311, -- smokev
[208] = 42, -- suzie
[273] = 307, -- tbone
[289] = 306, -- zero
[300] = 280, -- lapd1
[301] = 281, -- sfpd1
[302] = 282, -- lvpd1
[303] = 280, -- lapd1
[304] = 280, -- lapd1
[305] = 282, -- lvpd1
[306] = 211, -- wfyclot
[307] = 11, -- vbfycrp
[308] = 211, -- wfyclot
[309] = 211, -- wfyclot
[310] = 283, -- csher
[311] = 288 -- dsher
}

-- Left is SA-MP, right is MTA
g_BoneMapping = setmetatable({
[2] = 1, -- Head
Expand Down
8 changes: 8 additions & 0 deletions amx/server/events.lua
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,14 @@ addEventHandler('onPlayerSpawn', root,
procCallOnAll('OnPlayerSpawn', playerID)
setPlayerState(source, PLAYER_STATE_SPAWNED)

-- wanna see CJ in a white singlet?
addPedClothes(source, 'vest', 'vest', 0)

if not g_UseCJWalk then
local skin = getElementModel(source)
setPedWalkingStyle(source, WalkingStyle[skin] or 0)
end

if g_Players[playerID].updatetimer then
killTimer(g_Players[playerID].updatetimer)
end
Expand Down
3 changes: 2 additions & 1 deletion amx/server/natives/a_actors.lua
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
function CreateActor(amx, model, x, y, z, rotation)
local actor = createPed(model, x, y, z, rotation, false)
local actor = createPed(g_SkinReplace[model] or model, x, y, z, rotation, false)
addPedClothes(actor, 'vest', 'vest', 0)
setElementData(actor, 'ActorPed', true)
setElementData(actor, 'Invulnerable', true)
return addElem(g_Actors, actor)
Expand Down
17 changes: 14 additions & 3 deletions amx/server/natives/a_mta.lua
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,12 @@ function GetPlayerWalkingStyle(amx, player)
end

function SetPlayerWalkingStyle(amx, player, style)
-- if style is MOVE_DEFAULT and CJ walk isn't enabled
if style == 0 and not g_UseCJWalk then
-- return walking style back to default for this skin
local skin = getElementModel(player)
return setPedWalkingStyle(player, WalkingStyle[skin] or 0)
end
return setPedWalkingStyle(player, style)
end

Expand Down Expand Up @@ -118,6 +124,10 @@ function GetPlayerAmmoInClip(amx, player)
return getPedAmmoInClip(player)
end

function GetPlayerIdleTime(amx, player)
return getPlayerIdleTime(player)
end

function IsPlayerHeadless(amx, player)
return isPedHeadless(player)
end
Expand Down Expand Up @@ -169,7 +179,8 @@ end
-- Bots

function CreateBot(amx, model, x, y, z, name)
local bot = createPed(model, x, y, z)
local bot = createPed(g_SkinReplace[model] or model, x, y, z)
addPedClothes(bot, 'vest', 'vest', 0)
setElementData(bot, 'ShowNameTag', true)
setElementData(bot, 'BotName', name)
local botId = addElem(g_Bots, bot)
Expand Down Expand Up @@ -566,8 +577,8 @@ function SetTrainSpeed(amx, train, speed)
return setTrainSpeed(train, speed)
end

function GetVehicleDriver(amx, vehicle)
local player = getVehicleOccupant(vehicle)
function GetVehicleOccupant(amx, vehicle, seat)
local player = getVehicleOccupant(vehicle, seat)
if not player then
return INVALID_PLAYER_ID
end
Expand Down
Loading