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 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215
|
#include "CustomFiberThread.h"
#include "Scripting.h"
#include "../ScriptHook/Log.h"
#include <windows.h>
#include "KeyboardManager.h"
//#include "Variables.h"
#include <cstdio>
// Pull in all our scripting functions/types
using namespace Scripting;
i32 crap01 = 0; // Added crap01=0 and crap02=0 now cnrGoodModel and
i32 crap02 = 0; // cnrBadModel increment fine. Remove them and only one increments
i32 cnrGoodModel = 0;
i32 cnrBadModel = 0;
i32 cnrMaxBad = 29; //SET THIS APPROPRIATELY
i32 cnrMaxGood = 7; // SET APPROPRIATELY
b8 cnrIsModeGood = false;
Scripting::eModel cnrCopModels[8] = {MODEL_M_M_FATCOP_01,MODEL_M_M_FBI,MODEL_M_M_SECURITYMAN,MODEL_M_Y_COP,MODEL_M_Y_COP_TRAFFIC,MODEL_M_Y_STROOPER,MODEL_M_Y_SWAT,MODEL_IG_FRANCIS_MC};
Scripting::eModel cnrBadModels[30] = {MODEL_M_M_GBIK_LO_03,MODEL_M_Y_GBIK_HI_01,MODEL_M_Y_GBIK_HI_02,MODEL_M_Y_GBIK02_LO_02,MODEL_M_Y_GBIK_LO_01,MODEL_M_Y_GBIK_LO_02,MODEL_M_Y_GMAF_HI_01,MODEL_M_Y_GMAF_HI_02,MODEL_M_Y_GMAF_LO_01,MODEL_M_Y_GMAF_LO_02,MODEL_M_M_ALCOHOLIC,MODEL_M_M_CRACKHEAD,MODEL_M_M_ENFORCER,MODEL_M_M_GUNNUT_01,MODEL_M_O_MPMOBBOSS,MODEL_M_Y_DEALER,MODEL_M_Y_DRUG_01,MODEL_M_Y_GOON_01,MODEL_M_Y_PRISON,MODEL_M_Y_THIEF,MODEL_M_Y_JIM_FITZ,MODEL_M_Y_DODGY_01,MODEL_M_Y_STREET_01,MODEL_M_Y_STREET_03,MODEL_M_Y_STREET_04,MODEL_M_Y_STREETBLK_02,MODEL_M_Y_STREETBLK_03,MODEL_M_Y_STREETPUNK_02,MODEL_M_Y_STREETPUNK_04,MODEL_M_Y_STREETPUNK_05};
CustomFiberThread::CustomFiberThread()
{
// Give your own name here!
SetName("CnrAssistant");
}
// Some helper functions
Player CustomFiberThread::GetPlayer()
{
Player playerIndex = ConvertIntToPlayerIndex(GetPlayerId());
return playerIndex;
}
Scripting::Ped CustomFiberThread::GetPlayerPed()
{
Ped ped;
GetPlayerChar(GetPlayer(), &ped);
return ped;
}
void CustomFiberThread::SpawnCar(eModel model)
{
RequestModel(model);
while(!HasModelLoaded(model))
{
Wait(0);
}
LogInfo("Car model available... spawning it!");
Ped ped = GetPlayerPed();
Vehicle vehicle;
f32 x,y,z;
GetCharCoordinates(ped, &x, &y, &z);
CreateCar(model, x, y, z, &vehicle, true);
MarkModelAsNoLongerNeeded(model);
}
void CustomFiberThread::ChangePlayerSkin(eModel model)
{
RequestModel(model);
while(!HasModelLoaded(model))
{
Wait(0);
}
LogInfo("Skin model available... spawning it!");
eInteriorRoomKey roomKey;
GetKeyForCharInRoom(GetPlayerPed(), &roomKey);
ChangePlayerModel(GetPlayer(), model);
SetRoomForCharByKey(GetPlayerPed(), roomKey);
MarkModelAsNoLongerNeeded(model);
}
void CustomFiberThread::TeleportToWaypoint(Scripting::Ped &ped)
{
Blip b = GetFirstBlipInfoId(BLIP_WAYPOINT);
if(b.IsValid())
{
Vector3 v;
GetBlipCoords(b, &v);
LogInfo("Teleporting to %f, %f", v.X, v.Y);
// Thanks to Prince-Link for this magical Z coord detection code...
SetCharCoordinates(ped, v.X, v.Y, v.Z);
while(v.Z == 0.0f) // The chance that ground Z is 0.0 _exactly_ is really small
{
GetGroundZFor3DCoord(v.X, v.Y, 1000, &v.Z);
Wait(0);
}
SetCharCoordinates(ped, v.X, v.Y, v.Z);
}
else
{
LogError("No way point found to teleport to.");
}
}
void CustomFiberThread::OutputEx(char *displayString)
{
PrintStringWithLiteralStringNow("STRING", displayString, 2000, 1);
LogInfo("OUTPUT EX USED");
}
void CustomFiberThread::CycleModels()
{
if ( cnrIsModeGood )
{
if (Hotkey[RIGHT].pressed) {
if(++cnrGoodModel > cnrMaxGood) {
cnrGoodModel = 0;
}
ChangePlayerSkin(cnrCopModels[cnrGoodModel]);
}else if (Hotkey[LEFT].pressed) {
if(--cnrGoodModel < 0) {
cnrGoodModel = cnrMaxGood;
}
ChangePlayerSkin(cnrCopModels[cnrGoodModel]);
}
}
else
{
if (Hotkey[RIGHT].pressed) {
if(++cnrBadModel > cnrMaxBad) {
cnrBadModel = 0;
}
ChangePlayerSkin(cnrBadModels[cnrBadModel]);
}else if (Hotkey[LEFT].pressed) {
if(--cnrBadModel < 0) {
cnrBadModel = cnrMaxBad;
}
ChangePlayerSkin(cnrBadModels[cnrBadModel]);
}
}
SetAnimGroupForChar(GetPlayerPed(), "move_player");
}
void CustomFiberThread::CycleCurrentModel()
{
eModel GetCurMod;
if (cnrIsModeGood) {
GetCurMod = cnrCopModels[cnrGoodModel];
}else{
GetCurMod = cnrBadModels[cnrBadModel];
}
ChangePlayerSkin(GetCurMod);
SetAnimGroupForChar(GetPlayerPed(), "move_player");
}
void CustomFiberThread::IncrementTest() {
// USE AS TESTER FUNCTION
}
// The real script
void CustomFiberThread::RunScript()
{
// This is a fiber thread, so we use an loop to run the contents of this script.
// The thread will terminate when we return from this function.
keyboard_init();
while(IsThreadAlive())
{
keyboard_watch();
if ( Hotkey[CONTROL].pressed && Hotkey[DOWN].pressed )
{
cnrIsModeGood = !cnrIsModeGood;
OutputEx((cnrIsModeGood ? "Mode Set To: Good" : "Mode Set To: Bad"));
}
else if ( Hotkey[CONTROL].pressed && ( Hotkey[RIGHT].pressed || Hotkey[LEFT].pressed ) )
{
CycleModels();
}
else if ( Hotkey[CONTROL].pressed && Hotkey[ENTER].pressed )
{
CycleCurrentModel();
}
Wait(100);
}
}
|