├── .gitattributes ├── .gitignore ├── .travis.yml ├── LICENSE ├── README.md ├── pawn.json ├── running_styles.inc ├── samp_running_styles_version.inc └── test.pwn /.gitattributes: -------------------------------------------------------------------------------- 1 | *.pwn linguist-language=Pawn 2 | *.inc linguist-language=Pawn 3 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # 2 | # Package only files 3 | # 4 | 5 | # Compiled Bytecode, precompiled output and assembly 6 | *.amx 7 | *.lst 8 | *.asm 9 | 10 | # Vendor directory for dependencies 11 | dependencies/ 12 | 13 | # Dependency versions lockfile 14 | pawn.lock 15 | 16 | 17 | # 18 | # Server/gamemode related files 19 | # 20 | 21 | # compiled settings file 22 | # keep `samp.json` file on version control 23 | # but make sure the `rcon_password` field is set externally 24 | # you can use the environment variable `SAMP_RCON_PASSWORD` to do this. 25 | server.cfg 26 | 27 | # Plugins directory 28 | plugins/ 29 | 30 | # binaries 31 | *.exe 32 | *.dll 33 | *.so 34 | announce 35 | samp03svr 36 | samp-npc 37 | 38 | # logs 39 | logs/ 40 | server_log.txt 41 | crashinfo.txt 42 | 43 | # Ban list 44 | samp.ban 45 | 46 | # 47 | # Common files 48 | # 49 | 50 | *.sublime-workspace 51 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: cpp 2 | sudo: enabled 3 | install: 4 | - curl https://raw.githubusercontent.com/Southclaws/sampctl/master/install-deb.sh | sh 5 | - sudo dpkg --add-architecture i386 6 | - sudo apt update && sudo apt install -y g++-multilib 7 | script: 8 | - sampctl package ensure 9 | - sampctl package build 10 | - sampctl package run 11 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2021 Stefan Unković 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # samp-running-styles 2 | 3 | [![sampctl](https://img.shields.io/badge/Mergevos-samp--running--styles-2f2f2f.svg?style=for-the-badge)](https://github.com/Mergevos/samp-running-styles) 4 | 5 | Allows you to run in 13 styles. 6 | 7 | ## Installation 8 | 9 | Simply install to your project: 10 | 11 | ```bash 12 | sampctl package install Mergevos/samp-running-styles 13 | ``` 14 | 15 | Include in your code and begin using the library: 16 | 17 | ```pawn 18 | #include 19 | ``` 20 | 21 | ## Usage 22 | 23 | If you've had included this into your script/gamemode etc... Start by using a simple function 24 | ```pawn 25 | Player_SetRunningStyle(const playerid, const style); 26 | ``` 27 | This is going to set you some of running styles below 28 | ```pawn 29 | enum 30 | { 31 | RUNNING_STYLE_DEFAULT = 0, 32 | RUNNING_STYLE_ARMED1, 33 | RUNNING_STYLE_ARMED, 34 | RUNNING_STYLE_CIVIL, 35 | RUNNING_STYLE_CHAINSHAW, 36 | RUNNING_STYLE_FAT, 37 | RUNNING_STYLE_FAT_OLD, 38 | RUNNING_STYLE_GANG1, 39 | RUNNING_STYLE_LEFT, 40 | RUNNING_STYLE_OLD, 41 | RUNNING_STYLE_PLAYER, 42 | RUNNING_STYLE_RIGHT, 43 | RUNNING_STYLE_ROCKET, 44 | RUNNING_STYLE_BLIND 45 | }; 46 | ``` 47 | And there is 48 | ```pawn 49 | Player_GetRunningStyle(const playerid); 50 | ``` 51 | This will return you the player's running style. 52 | 53 | *Note*: If you've set the player's running style, to activate it, just press W key 54 | 55 | ## Testing 56 | 57 | 61 | 62 | To test, simply run the package: 63 | 64 | ```bash 65 | sampctl package run 66 | ``` 67 | -------------------------------------------------------------------------------- /pawn.json: -------------------------------------------------------------------------------- 1 | { 2 | "user": "Mergevos", 3 | "repo": "samp-running-styles", 4 | "entry": "test.pwn", 5 | "output": "test.amx", 6 | "dependencies": [ 7 | "sampctl/samp-stdlib" 8 | ], 9 | "dev_dependencies": [ 10 | "pawn-lang/YSI-Includes@5.x", 11 | "Y-Less/sscanf" 12 | ], 13 | "runtime": { 14 | "version": "0.3.7", 15 | "mode": "server", 16 | "rcon_password": "password", 17 | "port": 7777, 18 | "hostname": "SA-MP Server", 19 | "maxplayers": 50, 20 | "language": "" 21 | } 22 | } -------------------------------------------------------------------------------- /running_styles.inc: -------------------------------------------------------------------------------- 1 | /** 2 | @ Author: Mergevos 3 | @ Date: 23rd June 4 | @ Git: github.com/Mergevos/samp-running-styles 5 | @ Copyright (C) 2020 6 | @ About: 7 | - This include gives you access to 14 running styles 8 | **/ 9 | 10 | #if defined _running_Styles_inc 11 | #endinput 12 | #endif 13 | 14 | #define _running_Styles_inc 15 | 16 | #include 17 | 18 | // -- 19 | // Credits 20 | // -- 21 | 22 | #if !defined RUNNING_STYLES_NO_CREDITS_MSG 23 | public OnGameModeInit() 24 | { 25 | #if defined RS_OnGameModeInit 26 | RS_OnGameModeInit(); 27 | #endif 28 | print("[1.0.1] Running styles loaded \nCreated by Mergevos"); 29 | return 1; 30 | } 31 | #endif 32 | 33 | // -- 34 | // Running styles 35 | // -- 36 | 37 | 38 | static const TIME_UPDATE_ANIMATION = 300; 39 | 40 | enum e_RUNNING_STYLES 41 | { 42 | E_RUNNING_STYLE_DEFAULT = 0, 43 | E_RUNNING_STYLE_ARMED1, 44 | E_RUNNING_STYLE_ARMED, 45 | E_RUNNING_STYLE_CIVIL, 46 | E_RUNNING_STYLE_CHAINSHAW, 47 | E_RUNNING_STYLE_FAT, 48 | E_RUNNING_STYLE_FAT_OLD, 49 | E_RUNNING_STYLE_GANG1, 50 | E_RUNNING_STYLE_LEFT, 51 | E_RUNNING_STYLE_OLD, 52 | E_RUNNING_STYLE_PLAYER, 53 | E_RUNNING_STYLE_RIGHT, 54 | E_RUNNING_STYLE_ROCKET, 55 | E_RUNNING_STYLE_BLIND 56 | }; 57 | 58 | // -- 59 | // Vars 60 | // -- 61 | 62 | static 63 | Running_gsTimer[MAX_PLAYERS], 64 | e_RUNNING_STYLES: Running_gsStyle[MAX_PLAYERS]; 65 | 66 | static const Running_gsAnimIndices[] = {1222, 1223, 1224, 1225, 1226, 1227, 1228, 1229, 1230, 1232, 1233, 1236}; 67 | //indices animations for checking running 68 | 69 | static const Running_gsAnimations[][] = 70 | { 71 | "run_1armed", 72 | "run_armed", 73 | "run_civi", 74 | "run_csaw", 75 | "run_fat", 76 | "run_fatold", 77 | "run_gang1", 78 | "run_left", 79 | "run_old", 80 | "run_player", 81 | "run_right", 82 | "run_rocket", 83 | "Run_Wuzi" 84 | }; 85 | // -- 86 | // OnPlayerConnect 87 | // -- 88 | 89 | public OnPlayerConnect(playerid) 90 | { 91 | #if defined RS_OnPlayerConnect 92 | RS_OnPlayerConnect(playerid); 93 | #endif 94 | Running_gsStyle[playerid] = E_RUNNING_STYLE_DEFAULT; 95 | Running_gsTimer[playerid] = -1; 96 | return 1; 97 | } 98 | // -- 99 | // OnPlayerDisconnect 100 | // -- 101 | public OnPlayerDisconnect(playerid, reason) 102 | { 103 | 104 | #if defined RS_OnPlayerDisconnect 105 | RS_OnPlayerDisconnect(playerid, reason); 106 | #endif 107 | if(Running_gsTimer[playerid] != -1) 108 | { 109 | KillTimer(Running_gsTimer[playerid]); 110 | } 111 | return 1; 112 | } 113 | // -- 114 | // OnPlayerUpdate 115 | // -- 116 | public OnPlayerUpdate(playerid) 117 | { 118 | #if defined RS_OnPlayerUpdate 119 | RS_OnPlayerUpdate(playerid); 120 | #endif 121 | if(Player_GetRunningStyle(playerid) > 0 && Running_gsTimer[playerid] == -1) 122 | { 123 | new keys, updown, leftright; 124 | GetPlayerKeys(playerid,keys,updown,leftright); 125 | if (((!!updown || !!leftright) )) 126 | { 127 | new temp_index_anim = GetPlayerAnimationIndex(playerid); 128 | for(new i = 0; i < sizeof Running_gsAnimIndices; i++) 129 | { 130 | if(temp_index_anim == Running_gsAnimIndices[i]) 131 | { 132 | ApplyAnimation(playerid,"PED",Running_gsAnimations[_:Running_gsStyle[playerid]-1],4.1,1,1,1,1,1); 133 | timer_RunAnimation(playerid); 134 | break; 135 | } 136 | } 137 | } 138 | } 139 | return 1; 140 | } 141 | 142 | // -- 143 | // Handles timer_RunAnimation timer 144 | // -- 145 | 146 | forward timer_RunAnimation(playerid); 147 | public timer_RunAnimation(playerid) 148 | { 149 | Running_gsTimer[playerid] = -1; 150 | if(Running_gsStyle[playerid] <= E_RUNNING_STYLE_DEFAULT) 151 | { 152 | return 0; 153 | } 154 | new keys, updown, leftright; 155 | GetPlayerKeys(playerid,keys,updown,leftright); 156 | if (((!!updown || !!leftright) )) 157 | { 158 | new temp_index_anim = GetPlayerAnimationIndex(playerid); 159 | for(new i = 0; i < sizeof Running_gsAnimIndices; i++) 160 | { 161 | if(temp_index_anim == Running_gsAnimIndices[i]) 162 | { 163 | Running_gsTimer[playerid] = SetTimerEx("timer_RunAnimation",TIME_UPDATE_ANIMATION,false,"d",playerid); 164 | return 1; 165 | } 166 | } 167 | } 168 | return ApplyAnimation(playerid,"PED",Running_gsAnimations[_:Running_gsStyle[playerid]-1],4.0,0,0,0,0,1); 169 | } 170 | 171 | // -- 172 | // Sets player's running style 173 | // -- 174 | 175 | stock Player_SetRunningStyle(playerid, e_RUNNING_STYLES: style) 176 | { 177 | if(_:style >= sizeof(Running_gsAnimations)) 178 | { 179 | return 0; 180 | } 181 | Running_gsStyle[playerid] = style; 182 | return 1; 183 | } 184 | 185 | // -- 186 | // Gets player's running style 187 | // -- 188 | 189 | 190 | stock Player_GetRunningStyle(playerid) 191 | { 192 | return Running_gsStyle[playerid]; 193 | } 194 | 195 | // -- 196 | // ALS OnPlayerConnect 197 | // -- 198 | 199 | #if defined _ALS_OnPlayerConnect 200 | #undef OnPlayerConnect 201 | #else 202 | #define _ALS_OnPlayerConnect 203 | #endif 204 | #define OnPlayerConnect RS_OnPlayerConnect 205 | #if defined RS_OnPlayerConnect 206 | forward RS_OnPlayerConnect(playerid); 207 | #endif 208 | 209 | 210 | // -- 211 | // ALS OnPlayerDisconnect 212 | // -- 213 | 214 | #if defined _ALS_OnPlayerDisconnect 215 | #undef OnPlayerDisconnect 216 | #else 217 | #define _ALS_OnPlayerDisconnect 218 | #endif 219 | #define OnPlayerDisconnect RS_OnPlayerDisconnect 220 | #if defined RS_OnPlayerDisconnect 221 | forward RS_OnPlayerDisconnect(playerid, reason); 222 | #endif 223 | 224 | // -- 225 | // ALS OnGameModeInit 226 | // -- 227 | 228 | #if defined _ALS_OnGameModeInit 229 | #undef OnGameModeInit 230 | #else 231 | #define _ALS_OnGameModeInit 232 | #endif 233 | #define OnGameModeInit RS_OnGameModeInit 234 | #if defined RS_OnGameModeInit 235 | forward RS_OnGameModeInit(); 236 | #endif 237 | 238 | 239 | // -- 240 | // ALS OnPlayerUpdate 241 | // -- 242 | 243 | #if defined _ALS_OnPlayerUpdate 244 | #undef OnPlayerUpdate 245 | #else 246 | #define _ALS_OnPlayerUpdate 247 | #endif 248 | 249 | #define OnPlayerUpdate RS_OnPlayerUpdate 250 | #if defined RS_OnPlayerUpdate 251 | forward RS_OnPlayerUpdate(playerid); 252 | #endif 253 | -------------------------------------------------------------------------------- /samp_running_styles_version.inc: -------------------------------------------------------------------------------- 1 | // This file was generated by "sampctl package release" 2 | // DO NOT EDIT THIS FILE MANUALLY! 3 | // To update the version number for a new release, run "sampctl package release" 4 | 5 | #define SAMP_RUNNING_STYLES_VERSION_MAJOR (1) 6 | #define SAMP_RUNNING_STYLES_VERSION_MINOR (0) 7 | #define SAMP_RUNNING_STYLES_VERSION_PATCH (1) 8 | -------------------------------------------------------------------------------- /test.pwn: -------------------------------------------------------------------------------- 1 | #include 2 | #include "running_styles.inc" 3 | 4 | #include // use y_commands by Y_LESS 5 | #include // For va_ funcs by Y_LESS 6 | #include // For commands by Y_LESS 7 | 8 | main() 9 | { 10 | print("running_styles tests by Mergevos loaded "); 11 | } 12 | 13 | public OnPlayerConnect(playerid) 14 | { 15 | SetSpawnInfo(playerid, 0, 0, 811.1299,-1616.0647,13.5469, 0, 0,0,0,0,0,0); 16 | SpawnPlayer(playerid); 17 | return 1; 18 | } 19 | 20 | public OnPlayerSpawn(playerid) 21 | { 22 | TogglePlayerControllable(playerid, true); 23 | return 1; 24 | } 25 | 26 | YCMD:style(playerid, params[], help) 27 | { 28 | 29 | new style; 30 | if(sscanf(params, "i", style)) return SendClientMessage(playerid, -1, "Usage: /style "); 31 | va_SendClientMessage(playerid, -1, "Successfully set running style to: %i", style); 32 | Player_SetRunningStyle(playerid, e_RUNNING_STYLES: style ); 33 | return 1; 34 | } --------------------------------------------------------------------------------