Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * Walk
- * Author: Willie (Wojciech Drzymała)
- * Version: 1.0
- * Copyright (c) 2016
- *
- native TogglePlayerWalking(playerid, bool:toggle);
- native IsPlayerWalking(playerid);
- */
- #if defined _walk_included
- #endinput
- #endif
- #define _walk_included Oh, Yiss!
- /*
- * _walk PVar modes:
- * 0 = player is not being forced to walk
- * 1 = player is being forced to walk
- * 2 = player walking animation is turned on
- * 3 = player walking mode is suspended
- * 4 = player is going to the vehicle
- */
- stock TogglePlayerWalking(playerid, bool:toggle)
- {
- if(!IsPlayerConnected(playerid)) return;
- if(toggle)
- {
- if(IsPlayerInAnyVehicle(playerid)) SetPVarInt(playerid, "_walk", 3);
- else SetPVarInt(playerid, "_walk", 1);
- }
- else DeletePVar(playerid, "_walk");
- }
- #if defined IsPlayerWalking
- #undef IsPlayerWalking
- #endif
- #define IsPlayerWalking(%0) GetPVarInt(%0,"_walk")
- public OnPlayerUpdate(playerid)
- {
- new w = GetPVarInt(playerid, "_walk");
- if(!w) { if(funcidx("_alt_OnPlayerUpdate") != -1) return CallLocalFunction("_alt_OnPlayerUpdate", "i", playerid); else return 1; }
- if(w==1 || w==2)
- {
- if(IsPlayerInAnyVehicle(playerid))
- {
- ClearAnimations(playerid);
- SetPVarInt(playerid, "_walk", 3);
- if(funcidx("_alt_OnPlayerUpdate") != -1) return CallLocalFunction("_alt_OnPlayerUpdate", "i", playerid); else return 1;
- }
- new k, ud, lr;
- GetPlayerKeys(playerid, k, ud, lr);
- if(k & KEY_SECONDARY_ATTACK)
- {
- new Float:p[3];
- for(new x; x != MAX_VEHICLES; x++)
- {
- GetVehiclePos(x, p[0], p[1], p[2]);
- if(IsPlayerInRangeOfPoint(playerid, 5.0, p[0], p[1], p[2]))
- {
- SetPVarFloat(playerid, "_walk4MODEx", p[0]);
- SetPVarFloat(playerid, "_walk4MODEy", p[1]);
- SetPVarFloat(playerid, "_walk4MODEz", p[2]);
- SetPVarInt(playerid, "_walk", 4);
- SetTimerEx("_walkReturn", 5000, 0, "i", playerid);
- if(funcidx("_alt_OnPlayerUpdate") != -1) return CallLocalFunction("_alt_OnPlayerUpdate", "i", playerid); else return 1;
- }
- }
- }
- if(ud || (lr && !ud))
- {
- if(w==1)
- {
- ClearAnimations(playerid);
- ApplyAnimation(playerid, "ped", "null", 1.0, 1, 1, 1, 0, 0);
- ApplyAnimation(playerid, "ped", "WALK_player", 2.0, 1, 1, 1, 0, 0);
- SetPVarInt(playerid, "_walk", 2);
- }
- }
- else
- {
- ClearAnimations(playerid);
- SetPVarInt(playerid, "_walk", 1);
- if(funcidx("_alt_OnPlayerUpdate") != -1) return CallLocalFunction("_alt_OnPlayerUpdate", "i", playerid); else return 1;
- }
- new Float:fa;
- GetPlayerFacingAngle(playerid, fa);
- if((lr<0)&&(ud!=0)) SetPlayerFacingAngle(playerid, fa+5);
- else if((lr>0)&&(ud!=0)) SetPlayerFacingAngle(playerid, fa-5);
- else if((lr<0)&&(!ud)) SetPlayerFacingAngle(playerid, fa+13);
- else if((lr>0)&&(!ud)) SetPlayerFacingAngle(playerid, fa-13);
- }
- if(w==3)
- {
- if(IsPlayerInAnyVehicle(playerid)) { if(funcidx("_alt_OnPlayerUpdate") != -1) return CallLocalFunction("_alt_OnPlayerUpdate", "i", playerid); else return 1; }
- SetPVarInt(playerid, "_walk", 1);
- }
- if(w==4)
- {
- if(IsPlayerInAnyVehicle(playerid))
- {
- SetPVarInt(playerid, "_walk", 3);
- if(funcidx("_alt_OnPlayerUpdate") != -1) return CallLocalFunction("_alt_OnPlayerUpdate", "i", playerid); else return 1;
- }
- new Float:p[3];
- p[0] = GetPVarFloat(playerid, "_walk4MODEx");
- p[1] = GetPVarFloat(playerid, "_walk4MODEy");
- p[2] = GetPVarFloat(playerid, "_walk4MODEz");
- if(!IsPlayerInRangeOfPoint(playerid, 5.0, p[0], p[1], p[2]))
- {
- SetPVarInt(playerid, "_walk", 1);
- DeletePVar(playerid, "_walk4MODEx");
- DeletePVar(playerid, "_walk4MODEy");
- DeletePVar(playerid, "_walk4MODEz");
- }
- }
- if(funcidx("_alt_OnPlayerUpdate") != -1) return CallLocalFunction("_alt_OnPlayerUpdate", "i", playerid);
- else return 1;
- }
- #if defined _ALS_OnPlayerUpdate
- #undef OnPlayerUpdate
- #else
- #define _ALS_OnPlayerUpdate
- #endif
- #define OnPlayerUpdate _alt_OnPlayerUpdate
- forward _alt_OnPlayerUpdate(playerid);
- forward _walkReturn(playerid);
- public _walkReturn(playerid)
- {
- if(!GetPVarInt(playerid, "_walk")) return;
- if(IsPlayerInAnyVehicle(playerid)) SetPVarInt(playerid, "_walk", 3);
- else SetPVarInt(playerid, "_walk", 1);
- DeletePVar(playerid, "_walk4MODEx");
- DeletePVar(playerid, "_walk4MODEy");
- DeletePVar(playerid, "_walk4MODEz");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement