Quantcast

Jump to content

» «
Photo

How to use Aru's C++ ScriptHook SDK

30 replies to this topic
Skorpro
  • Skorpro

    GTAholic

  • Members
  • Joined: 19 Jul 2009
  • Germany

#1

Posted 24 August 2013 - 09:40 AM Edited by Skorpro, 13 September 2013 - 02:37 AM.

Hi modders,

after some requests I decided to post here my small instruction how to use Aru's C++ ScriptHook SDK. I wrote this "HOW TO" some time ago for friends smile.gif

Let's go! Simply follow the instructions biggrin.gif

  • First install Visual C++ 2010 Express and Aru's C++ Script Hook SDK 0.4.0!
  • Then run ScriptHook.sln (C++ ScriptHook SDK)... alter loading double click on SampleCustomFiber (left menu) >> Source Files >> CustomFiberThread.cpp
  • Edit the script like YOU want smile.gif(You can find examples in SDK!)
  • Right click on SampleCustomFiber (left menu) and choose "Set as StartUp Project"!
  • At the top of the window you can see a green PLAYbutton! Besides ("DEBUG") choose "RELEASE" and press PLAY!
  • You get a message like an error >> ignore this and press OK.
  • Go to ScriptHook SDK main folder and you will see a folder called Release. There you can find this file: SampleCustomFiber.dll
    Rename it to "myTestMod.asi" (NOT myTestMod.asi.dll !!!!) and copy it to your GTA game dir (root dir)!
  • Congratulations! Your first mod is ready now!
  • Start the game to test it... Have fun smile.gif

Here is a list with about 250 natives that I have edited! You must edit your "ScriptingNatives.h" too, so download both HERE!

 
// ##########################################
// ######## Natives edited by Skorpro #######
// ##########################################

// Vehicle, Car...
TurnOffVehicleExtra(Vehicle vehicle, int extraID, b8 extraOnOff)  ==>>  TURN_OFF_VEHICLE_EXTRA
SetCanBurstCarTyres(Vehicle vehicle, b8 value)  ==>>  SET_CAN_BURST_CAR_TYRES
SetCarCollision(Vehicle vehicle, b8 collOnOff)  ==>>  SET_CAR_COLLISION
AttachCarToCar(Vehicle newVeh, Vehicle myCurrentVeh, int zero, f32 x, f32 y, f32 z, f32 rotax, f32 rotay, f32 rotaz)  ==>>  ATTACH_CAR_TO_CAR
TaskCarDriveToCoord(Ped ped, Vehicle car, float x, float y, float z, float speed, unsigned int p1f_2b, unsigned int p2, unsigned int p3, unsigned int px2, unsigned int p45000)  ==>>  TASK_CAR_DRIVE_TO_COORD
SetVehHasStrongAxles(Vehicle vehicle, b8 axlesOnOff)  ==>>  SET_VEH_HAS_STRONG_AXLES
SetCarEngineOn(Vehicle vehicle, int var0, int var1)  ==>>  SET_CAR_ENGINE_ON
SetCarAsMissionCar(Vehicle vehicle)  ==>>  SET_CAR_AS_MISSION_CAR
SetCarCoordinatesNoOffset(Vehicle vehicle, f32 x, f32 y, f32 z)  ==>>  SET_CHAR_COORDINATES_NO_OFFSET
AddStuckCarCheckWithWarp(Vehicle vehicle, f32 stuckdif, int time, bool flag1, bool flag2, bool flag3, bool flag4)  ==>>  ADD_STUCK_CAR_CHECK_WITH_WARP
IsVehStuck(Vehicle vehicle, int time, bool flag1, bool flag2, bool flag3)  ==>>  IS_VEH_STUCK
SetCarLivery(Vehicle vehicle, int liveryID)  ==>>  SET_CAR_LIVERY
TakeCarOutOfParkedCarsBudget(Vehicle vehicle, b8 onOff)  ==>>  TAKE_CAR_OUT_OF_PARKED_CARS_BUDGET
SuppressCarModel(eModel model)  ==>>  SUPPRESS_CAR_MODEL
SetVehIndicatorlights(Vehicle vehicle, b8 set)  ==>>  SET_VEH_INDICATORLIGHTS
SetPetrolTankWeakpoint(Vehicle vehicle, b8 set)  ==>>  SET_PETROL_TANK_WEAKPOINT
AttachObjectToCarPhysically(Object obj, Vehicle v, u32 carParts, u32 carParts2, f32 pX, f32 pY, f32 pZ, f32 unkX, f32 unkY, f32 unkZ, f32 rX, f32 rY, f32 rZ, f32 unkHealth, b8 unkTrue)  ==>>  ATTACH_OBJECT_TO_CAR_PHYSICALLY
TriggerPtfxOnVeh(const ch *fxName, Vehicle veh, f32 x, f32 y, f32 z, f32 xspeed, f32 yspeed, f32 zspeed, f32 radius)  ==>>  TRIGGER_PTFX_ON_VEH
GetVehicleComponentInfo(Vehicle veh, int component_id_41, Vector3 *pPosition1, Vector3 *pPosition2, int *pMinus1, bool flag)  ==>>  GET_VEHICLE_COMPONENT_INFO
GetCarForwardVector(Vehicle veh, Vector3 *pVeh)  ==>>  GET_CAR_FORWARD_VECTOR
GetVehicleQuaternion(Vehicle vehicle, f32 *px, f32 *py, f32 *pz, f32 *pa)  ==>>  GET_VEHICLE_QUATERNION
ShiftLeft(int val)  ==>>  SHIFT_LEFT
ShiftRight(int val)  ==>>  SHIFT_RIGHT
SetCarLaneShift(Vehicle vehicle, f32 shift)  ==>>  SET_CAR_LANE_SHIFT
AttachCarToObject(Vehicle car, Object obj, u32 unknown0_0, f32 pX, f32 pY, f32 pZ, f32 rX, f32 rY, f32 rZ)  ==>>  ATTACH_CAR_TO_OBJECT
GetCarLivery(Vehicle vehicle, int *liveryID)  ==>>  GET_CAR_LIVERY
LocateCar3D(Vehicle veh, f32 x, f32 y, f32 z, f32 radx, f32 rady, f32 radz, b8 flag)  ==>>  LOCATE_CAR_3D
LocateCharInCar3D(Ped ped, f32 x, f32 y, f32 z, f32 radx, f32 rady, f32 radz, b8 flag)  ==>>  LOCATE_CHAR_IN_CAR_3D
IsCarStuck(Vehicle vehicle)  ==>>  IS_CAR_STUCK
CreateCarGenerator(f32 x, f32 y, f32 z, f32 angle, f32 unk0, f32 unk1, eModel model, int unk2, int unk3, int unk4, int unk5, int unk6, int alarm, int doorlock,int *carGen)  ==>>  CREATE_CAR_GENERATOR
DeleteCarGenerator(int carGen)  ==>>  DELETE_CAR_GENERATOR
SwitchCarGenerator(int carGen, int type_0_101_1000)  ==>>  SWITCH_CAR_GENERATOR
DisableCarGenerators(b8 flag0, b8 flag1)  ==>>  DISABLE_CAR_GENERATORS
SetHasBeenOwnedForCarGenerator(int carGen, b8 set)  ==>>  SET_HAS_BEEN_OWNED_FOR_CAR_GENERATOR
SetAllCarGeneratorsBackToActive()  ==>>  SET_ALL_CAR_GENERATORS_BACK_TO_ACTIVE
DisableCarGeneratorsWithHeli(bool trueFalse)  ==>>  DISABLE_CAR_GENERATORS_WITH_HELI
SetCarGeneratorsActiveInArea(f32 x1, f32 y1, f32 z1, f32 x2, f32 y2, f32 z2, bool set)  ==>>  SET_CAR_GENERATORS_ACTIVE_IN_AREA
GetVehiclePlayerWouldEnter(Player playerIndex, Vehicle *veh)  ==>>  GET_VEHICLE_PLAYER_WOULD_ENTER

// Player, Peds (Char)...
SetCharCollision(Ped ped, b8 collOnOff)  ==>>  SET_CHAR_COLLISION
SetCharCoordinatesNoOffset(Ped ped, f32 x, f32 y, f32 z)  ==>>  SET_CHAR_COORDINATES_NO_OFFSET
SetUseLegIK(Player playerIndex, bool trueFalse)  ==>>  SET_USE_LEG_IK
TaskShuffleToNextCarSeat(Ped ped, Vehicle vehicle)  ==>>  TASK_SHUFFLE_TO_NEXT_CAR_SEAT
SetCharWillLeaveCarInCombat(Ped ped, bool trueFalse)  ==>>  SET_CHAR_WILL_LEAVE_CAR_IN_COMBAT
AllowTargetWhenInjured(Ped ped, bool trueFalse)  ==>>  ALLOW_TARGET_WHEN_INJURED
SetCharMeleeActionFlag0(Ped ped, bool trueFalse)  ==>>  SET_CHAR_MELEE_ACTION_FLAG0
SetCharMeleeActionFlag1(Ped ped, bool trueFalse)  ==>>  SET_CHAR_MELEE_ACTION_FLAG1
SetCharMeleeActionFlag2(Ped ped, bool trueFalse)  ==>>  SET_CHAR_MELEE_ACTION_FLAG2
SetCharStayInCarWhenJacked(Ped ped, bool trueFalse)  ==>>  SET_CHAR_STAY_IN_CAR_WHEN_JACKED
ResetVisiblePedDamage(Ped ped)  ==>>  RESET_VISIBLE_PED_DAMAGE
SetPlayerKeepsWeaponsWhenRespawned(Player playerIndex)  ==>>  SET_PLAYER_KEEPS_WEAPONS_WHEN_RESPAWNED
SuppressPedModel(eModel model)  ==>>  SUPPRESS_PED_MODEL
RegisterTarget(Ped ped, Ped targetped)  ==>>  REGISTER_TARGET
TaskShootAtChar(Ped shooter, Ped victim, int time, int shootmode)  ==>>  TASK_SHOOT_AT_CHAR
LocateCharAnyMeansChar3D(Ped anyPed, Ped playerPed, f32 x, f32 y, f32 z, b8 flag)  ==>>  LOCATE_CHAR_ANY_MEANS_CHAR_3D
BlockCharAmbientAnims(Ped ped, bool onOff)  ==>>  BLOCK_CHAR_AMBIENT_ANIMS
SetCharAngledDefensiveArea(Ped ped, f32 ax, f32 ay, f32 az, f32 bx, f32 by, f32 bz, f32 angle)  ==>>  SET_CHAR_ANGLED_DEFENSIVE_AREA
AttachPedToObject(Ped ped, Object obj, ePedBone bone, f32 X, f32 Y, f32 Z, f32 A, f32 unk0, b8 unk1, b8 unk2)  ==>>  ATTACH_PED_TO_OBJECT
LocateCharOnFoot3D(Ped ped, f32 x, f32 y, f32 z, f32 radx, f32 rady, f32 radz, b8 flag)  ==>>  LOCATE_CHAR_ON_FOOT_3D
SetDrawPlayerComponent(ePedComponent component, b8 set)  ==>>  SET_DRAW_PLAYER_COMPONENT
TaskClimbLadder(Ped ped, bool trueFalse)  ==>>  TASK_CLIMB_LADDER

// Objects & Doors
SetObjectAlpha(Object obj, int alpha)  ==>>  SET_OBJECT_ALPHA
SetObjectHealth(Object obj, f32 health)  ==>>  SET_OBJECT_HEALTH
SetObjectRotation(Object obj, f32 rotax, f32 rotay, f32 rotaz)  ==>>  SET_OBJECT_ROTATION
SetObjectOnlyDamagedByPlayer(Object obj, b8 damOnOff)  ==>>  SET_OBJECT_ONLY_DAMAGED_BY_PLAYER
SlideObject(Object obj, f32 x, f32 y, f32 z, f32 xspeed, f32 yspeed, f32 zspeed, int one)  ==>>  SLIDE_OBJECT
StartPtfxOnObj(const ch *fxName, Object obj, f32 x, f32 y, f32 z, f32 xspeed, f32 yspeed, f32 zspeed, f32 radius)  ==>>  START_PTFX_ON_OBJ
TriggerPtfxOnObj(const ch *fxName, Object obj, f32 x, f32 y, f32 z, f32 xspeed, f32 yspeed, f32 zspeed, f32 radius)  ==>>  TRIGGER_PTFX_ON_OBJ
SetObjectProofs(Object object, b8 bulletProof, b8 fireProof, b8 explosionProof, b8 collisionProof, b8 meleeProof)  ==>>  SET_OBJECT_PROOFS
RotateObject(Object obj, float angle, float rotSpeed, int nullEins)  ==>>  ROTATE_OBJECT
GetClosestStealableObject(f32 x, f32 y, f32 z, f32 radius, Object *obj)  ==>>  GET_CLOSEST_STEALABLE_OBJECT
SetObjectScale(Object obj, f32 scale)  ==>>  SET_OBJECT_SCALE
GetStateOfClosestDoorOfType(u32 model, f32 x, f32 y, f32 z, b8 *lock, f32 *doorswing)  ==>>  GET_STATE_OF_CLOSEST_DOOR_OF_TYPE
SetStateOfClosestDoorOfType(u32 model, f32 x, f32 y, f32 z, b8 lock, f32 doorswing)  ==>>  SET_STATE_OF_CLOSEST_DOOR_OF_TYPE
FindNearestCollectableBinBags(f32 x, f32 y, f32 z)  ==>>  FIND_NEAREST_COLLECTABLE_BIN_BAGS
FindNearestEntitiesWithSpecialAttribute(f32 x, f32 y, f32 z)  ==>>  FIND_NEAREST_ENTITIES_WITH_SPECIAL_ATTRIBUTE
LookAtNearbyEntityWithSpecialAttribute(i32 unkZero, Vector3 *pCoord, f32 *unkFloat, i32 *unkFlag, u32 *pModelHash, f32 *pRotation)  ==>>  LOOK_AT_NEARBY_ENTITY_WITH_SPECIAL_ATTRIBUTE
GrabNearbyObjectWithSpecialAttribute(i32 unkZero, Object *pObj)  ==>>  GRAB_NEARBY_OBJECT_WITH_SPECIAL_ATTRIBUTE
SetObjectQuaternion(Object obj, f32 x, f32 y, f32 z, f32 a)  ==>>  SET_OBJECT_QUATERNION
HasCollisionForModelLoaded(eModel model)  ==>>  HAS_COLLISION_FOR_MODEL_LOADED
RequestCollisionForModel(eModel model)  ==>>  REQUEST_COLLISION_FOR_MODEL
SetLoadCollisionForObjectFlag(Object obj, b8 set)  ==>>  SET_LOAD_COLLISION_FOR_OBJECT_FLAG
SetVisibilityOfClosestObjectOfType(f32 x, f32 y, f32 z, f32 radius, eModel typeOfModel, b8 set)  ==>>  SET_VISIBILITY_OF_CLOSEST_OBJECT_OF_TYPE
EnableDisabledAttractorsOnObject(Object obj, b8 enable)  ==>>  ENABLE_DISABLED_ATTRACTORS_ON_OBJECT

// Effects (Light, PTFX)...
DrawLightWithRange(f32 x, f32 y, f32 z, int r, int g, int b, f32 radius, f32 intensity)  ==>>  DRAW_LIGHT_WITH_RANGE
TriggerPtfxOnPedBone(const ch *fxName, Ped ped, f32 x, f32 y, f32 z, f32 xspeed, f32 yspeed, f32 zspeed, ePedBone bone, u32 flags)  ==>>  TRIGGER_PTFX_ON_PED_BONE
TriggerPtfxOnPed(const ch *fxName, Ped ped, f32 x, f32 y, f32 z, f32 xspeed, f32 yspeed, f32 zspeed, f32 radius)  ==>>  TRIGGER_PTFX_ON_PED
RemovePtfxFromPed(Player playerIndex)  ==>>  REMOVE_PTFX_FROM_PED
StartPtfx(const ch *fxName, f32 x, f32 y, f32 z, f32 xspeed, f32 yspeed, f32 zspeed, f32 radius)  ==>>  START_PTFX
TriggerPtfx(const ch *fxName, f32 x, f32 y, f32 z, f32 xspeed, f32 yspeed, f32 zspeed, f32 radius)  ==>>  TRIGGER_PTFX
StartPtfxOnPedBone(const ch *fxName, Ped ped, f32 x, f32 y, f32 z, f32 xspeed, f32 yspeed, f32 zspeed, ePedBone bone, u32 flags)  ==>>  START_PTFX_ON_PED_BONE

// Blip, Sphere, Pickups...
AddSphere(f32 x, f32 y, f32 z, f32 radius, int unknow)  ==>>  ADD_SPHERE
AddNEWSphere(f32 x, f32 y, f32 z, f32 radius, u32 unknow)  ==>>  ADD_SPHERE
RemoveNEWSphere(u32 sphere)  ==>>  REMOVE_SPHERE
RemoveSphere(const ch *sphere)  ==>>  REMOVE_SPHERE
DrawColouredCylinder(f32 x, f32 y, f32 z, f32 hoch, f32 breit, int col_red, int col_green, int col_blue, int alpha)  ==>>  DRAW_COLOURED_CYLINDER
CreatePickupRot(eModel model, u32 pickupType, u32 unknown, f32 x, f32 y, f32 z, f32 rX, f32 rY, f32 rZ, Pickup *pPickup)  ==>>  CREATE_PICKUP_ROTATE
SetPoliceRadarBlips(b8 onOff)  ==>>  SET_POLICE_RADAR_BLIPS
AddPickupToInteriorRoomByKey(Pickup pickup, eInteriorRoomKey roomKey)  ==>>  ADD_PICKUP_TO_INTERIOR_ROOM_BY_KEY
CreateCheckpoint(int type, f32 x1, f32 y1, f32 z1, f32 x2, f32 y2, f32 z2, f32 one)  ==>>  CREATE_CHECKPOINT
DeleteCheckpoint(u32 checkpoint)  ==>>  DELETE_CHECKPOINT

// Diverse, World, Script, Room...
IsControlPressed(int nullZwei, int sysKey)  ==>>  IS_CONTROL_PRESSED
DoesScriptExist(const ch *scriptName)  ==>>  DOES_SCRIPT_EXIST
RequestScript(const ch *scriptName)  ==>>  REQUEST_SCRIPT
SetThisScriptCanRemoveBlipsCreatedByAnyScript(b8 reBlip)  ==>>  SET_THIS_SCRIPT_CAN_REMOVE_BLIPS_CREATED_BY_ANY_SCRIPT
TerminateAllScriptsWithThisName(const ch *scriptName)  ==>>  TERMINATE_ALL_SCRIPTS_WITH_THIS_NAME
GetWaterHeight(f32 x, f32 y, f32 z, f32 *height)  ==>>  GET_WATER_HEIGHT
LoadPathNodesInArea(f32 x1, f32 y1, f32 x2, f32 y2)  ==>>  LOAD_PATH_NODES_IN_AREA
ReleasePathNodes()  ==>>  RELEASE_PATH_NODES
UpdateLoadScene()  ==>>  UPDATE_LOAD_SCENE
TurnOffRadioHUBInLobby()  ==>>  TURN_OFF_RADIOHUD_IN_LOBBY
SetPedNonCreationArea(f32 x1, f32 y1, f32 z1, f32 x2, f32 y2, f32 z2)  ==>>  SET_PED_NON_CREATION_AREA
LoadSceneForRoomByKey(Interior interior, eInteriorRoomKey roomKey)  ==>>  LOAD_SCENE_FOR_ROOM_BY_KEY
SetRoomForCarByKey(Vehicle car, eInteriorRoomKey key)  ==>>  SET_ROOM_FOR_CAR_BY_KEY
SetRoomForViewportByKey(int viewportid, eInteriorRoomKey key)  ==>>  SET_ROOM_FOR_VIEWPORT_BY_KEY
SetMinigameInProgress(b8 onOff)  ==>>  SET_MINIGAME_IN_PROGRESS
StartNewScript(const ch *scriptName, u32 stacksize)  ==>>  START_NEW_SCRIPT
AllocateScriptToObject(const ch *scriptName, u32 model, int unk, float radius, int UnkTime)  ==>>  ALLOCATE_SCRIPT_TO_OBJECT
IsModelInCDImage(eModel model)  ==>>  IS_MODEL_IN_CDIMAGE
SwapNearestBuildingModel(f32 x, f32 y, f32 z, f32 radius, eModel fromModel, eModel toModel)  ==>>  SWAP_NEAREST_BUILDING_MODEL
RegisterWorldPointScriptBrain(char *scriptName, f32 radius)  ==>>  REGISTER_WORLD_POINT_SCRIPT_BRAIN

// Traffic Control & SpeedUp
SetCarDensityMultiplier(f32 CarDensity)  ==>>  SET_CAR_DENSITY_MULTIPLIER
SetPedDensityMultiplier(f32 PedDensity)  ==>>  SET_PED_DENSITY_MULTIPLIER
SetRandomCarDensityMultiplier(f32 RandomCarDensity)  ==>>  SET_RANDOM_CAR_DENSITY_MULTIPLIER
SetParkedCarDensityMultiplier(f32 CarDensity)  ==>>  SET_PARKED_CAR_DENSITY_MULTIPLIER
DontSuppressCarModel(eModel carmodel)  ==>>  DONT_SUPPRESS_CAR_MODEL
DontSuppressAnyCarModel()  ==>>  DONT_SUPPRESS_CAR_MODEL
ForceRandomCarModel(eModel carmodel)  ==>>  FORCE_RANDOM_CAR_MODEL
DontSuppressPedModel(eModel pedmodel)  ==>>  DONT_SUPPRESS_PED_MODEL
DontSuppressAnyPedModels()  ==>>  DONT_SUPPRESS_ANY_PED_MODELS
AddAdditionalPopulationModel(eModel popmodel)  ==>>  ADD_ADDITIONAL_POPULATION_MODEL
RemoveAdditionalPopulationModel(eModel popmodel)  ==>>  REMOVE_ADDITIONAL_POPULATION_MODEL

// Emergency, Police & Undercover
PlaySoundFromVehicle(eSound sound, ch *soundName, Vehicle vehicle)  ==>>  PLAY_SOUND_FROM_VEHICLE, ScriptVoid>(sound, soundName, vehicle); }
SwitchCarSiren(Vehicle vehicle, b8 sirenOnOff)  ==>>  SWITCH_CAR_SIREN
SetSirenWithNoDriver(Vehicle vehicle, b8 sirenOnOff)  ==>>  SET_SIREN_WITH_NO_DRIVER
CreateEmergencyServicesCarReturnDriver(eModel modelPolCar, f32 x, f32 y, f32 z, Vehicle *vehiclePolCar, Ped *char1, Ped *char2)  ==>>  CREATE_EMERGENCY_SERVICES_CAR_RETURN_DRIVER
CreateEmergencyServicesCarThenWalk(eModel modelPolCar, f32 x, f32 y, f32 z)  ==>>  CREATE_EMERGENCY_SERVICES_CAR_THEN_WALK
SetMaxWantedLevel(int wantedLevel)  ==>>  SET_MAX_WANTED_LEVEL

// Camera
ActivateScriptedCams(int highDOF, int highDOF2)  ==>>  ACTIVATE_SCRIPTED_CAMS
AttachCamToPed(Camera camera, Ped ped)  ==>>  ATTACH_CAM_TO_PED
SetCamAttachOffset(Camera camera, f32 xoff, f32 yoff, f32 zoff)  ==>>  SET_CAM_ATTACH_OFFSET
SetCamAttachOffsetIsRelative(Camera camera, bool onOff)  ==>>  SET_CAM_ATTACH_OFFSET_IS_RELATIVE
PointCamAtPed(Camera camera, Ped ped)  ==>>  POINT_CAM_AT_PED
SetCamPointOffset(Camera camera, f32 xoff, f32 yoff, f32 zoff)  ==>>  SET_CAM_POINT_OFFSET
SetCamPointOffsetIsRelative(Camera camera, bool onOff)  ==>>  SET_CAM_POINT_OFFSET_IS_RELATIVE
AttachCamToObject(Camera camera, Object obj)  ==>>  ATTACH_CAM_TO_OBJECT
PointCamAtObject(Camera camera, Object obj)  ==>>  POINT_CAM_AT_PED
SetDrunkCam(Camera camera, f32 effect, u32 time)  ==>>  SET_DRUNK_CAM
ForceGameTelescopeCam(b8 force)  ==>>  FORCE_GAME_TELESCOPE_CAM
SetCamSplineSpeedGraph(Camera camera, int graph)  ==>>  SET_CAM_SPLINE_SPEED_GRAPH
SetCamSplineCustomSpeedGraph(f32 speed)  ==>>  SET_CAM_SPLINE_CUSTOM_SPEED_GRAPH
ResetCamSplineCustomSpeedGraph()  ==>>  RESET_CAM_SPLINE_CUSTOM_SPEED_GRAPH
SetCamInterpCustomSpeedGraph(f32 speed)  ==>>  SET_CAM_INTERP_CUSTOM_SPEED_GRAPH
ResetCamInterpCustomSpeedGraph()  ==>>  RESET_CAM_INTERP_CUSTOM_SPEED_GRAPH
CamSequenceOpen(int sequence)  ==>>  CAM_SEQUENCE_OPEN
CamSequenceStart(int sequence)  ==>>  CAM_SEQUENCE_START
CamSequenceWait(int sequence, u32 time)  ==>>  CAM_SEQUENCE_WAIT
IsCamSequenceComplete(int sequence)  ==>>  IS_CAM_SEQUENCE_COMPLETE
CamSequenceRemove(int sequence)  ==>>  CAM_SEQUENCE_REMOVE
CamSequenceStop(int sequence)  ==>>  CAM_SEQUENCE_STOP
CamSequenceClose()  ==>>  CAM_SEQUENCE_CLOSE
SetCamRoll(Camera camera, f32 roll)  ==>>  SET_CAM_ROLL
BeginCamCommands(int *num)  ==>>  BEGIN_CAM_COMMANDS
EndCamCommands(int *num)  ==>>  END_CAM_COMMANDS
CamSetCinematic(Vehicle veh, b8 set)  ==>>  CAM_SET_CINEMATIC
GetCinematicCam(Camera *camera)  ==>>  GET_CINEMATIC_CAM
ForceNoCamPause(b8 force)  ==>>  FORCE_NO_CAM_PAUSE
GetFreeCam(Camera *camera)  ==>>  GET_FREE_CAM
UnattachCam(Camera camera)  ==>>  UNATTACH_CAM
SetCamMotionBlur(Camera camera, f32 blur)  ==>>  SET_CAM_MOTION_BLUR
GetCamMotionBlur(Camera camera, int *blur)  ==>>  GET_CAM_MOTION_BLUR
SetViewportShape(Camera camera, int shape)  ==>>  SET_VIEWPORT_SHAPE
DestroyAllCams()  ==>>  DESTROY_ALL_CAMS
EnableCamCollision(Camera camera, b8 onOff)  ==>>  ENABLE_CAM_COLLISION
SetGameCameraControlsActive(b8 onOff)  ==>>  SET_GAME_CAMERA_CONTROLS_ACTIVE

// Text & GXT
ClearHelp()  ==>>  CLEAR_HELP
IsThisHelpMessageBeingDisplayed(const ch *gxtName)  ==>>  IS_THIS_HELP_MESSAGE_BEING_DISPLAYED

// NETWORK, Multiplayer...
IsNetworkPlayerActive(u32 playerId)  ==>>  IS_NETWORK_PLAYER_ACTIVE
NetworkKickPlayer(u32 playerId)  ==>>  NETWORK_KICK_PLAYER
NetworkKickPlayer2(u32 playerId, b8 yesNo)  ==>>  NETWORK_KICK_PLAYER
GivePedFakeNetworkName(Ped ped, char *name, u32 red, u32 green, u32 blue, u32 alpha)  ==>>  GIVE_PED_FAKE_NETWORK_NAME
UsePlayerColourInsteadOfTeamColour(b8 yesNo)  ==>>  USE_PLAYER_COLOUR_INSTEAD_OF_TEAM_COLOUR
SetPlayerIconColour(int color)  ==>>  SET_PLAYER_ICON_COLOUR
ThisScriptIsSafeForNetworkGame()  ==>>  THIS_SCRIPT_IS_SAFE_FOR_NETWORK_GAME
IsNetworkSession()  ==>>  IS_NETWORK_SESSION

// Weapons
GiveDelayedWeaponToChar(Ped ped, eWeapon weapon, int delay, bool flag)  ==>>  GIVE_DELAYED_WEAPON_TO_CHAR
SetCharCurrentWeaponVisible(Ped ped, b8 visible)  ==>>  SET_CHAR_CURRENT_WEAPON_VISIBLE
GetWeapontypeModel(eWeapon weapon, eModel *model)  ==>>  GET_WEAPONTYPE_MODEL

// Anims, Sequences & Screen
HasCharAnimFinished(Ped ped, ch *animSet, ch *animName)  ==>>  HAS_CHAR_ANIM_FINISHED
SetWidescreenBorders(b8 onOff)  ==>>  SET_WIDESCREEN_BORDERS
SetInstantWidescreenBorders(b8 onOff)  ==>>  SET_INSTANT_WIDESCREEN_BORDERS
IsSittingObjectNear(f32 x, f32 y, f32 z, int model_or_null)  ==>>  IS_SITTING_OBJECT_NEAR
TaskSitDownOnSeat(Ped ped, int u1, int u2, f32 x, f32 y, f32 z, f32 a, int minus2)  ==>>  TASK_SIT_DOWN_ON_SEAT
TaskSitDownOnNearestObject(Ped ped, int u1, int u2, f32 x, f32 y, f32 z, int model_or_null, f32 a, int minus2, int one)  ==>>  TASK_SIT_DOWN_ON_NEAREST_OBJECT
ClearNewsScrollbar()  ==>>  CLEAR_NEWS_SCROLLBAR
AddStringToNewsScrollbar(const ch *newsScrollText)  ==>>  ADD_STRING_TO_NEWS_SCROLLBAR
ChangeCharSitIdleAnim(Ped ped, const ch *animSet, const ch *animName, int oneOrNull)  ==>>  CHANGE_CHAR_SIT_IDLE_ANIM
TaskPlayAnimNonInterruptable(Ped ped, const ch *animName, const ch *animSet, f32 unk1, int RepeatIsONE, int unk2, int unk3, int unk4, int unk5)  ==>>  TASK_PLAY_ANIM_NON_INTERRUPTABLE
ClearNamedCutscene(char *name)  ==>>  CLEAR_NAMED_CUTSCENE
InitCutscene(char *name)  ==>>  INIT_CUTSCENE
StopCutscene()  ==>>  STOP_CUTSCENE

// Sound & Audio & Radio & TV & Movie & Stream
PlayAudioEventFromPed(const ch *audioName, Ped ped)  ==>>  PLAY_AUDIO_EVENT_FROM_PED
PlayAudioEventFromVehicle(const ch *audioName, Vehicle veh)  ==>>  PLAY_AUDIO_EVENT_FROM_VEHICLE
PlayAudioEventFromObject(const ch *audioName, Object obj)  ==>>  PLAY_AUDIO_EVENT_FROM_OBJECT
MutePositionedRadio(b8 yesNo)  ==>>  MUTE_POSITIONED_RADIO
MuteGameworldAndPositionedRadioForTv(b8 yesNo)  ==>>  MUTE_GAMEWORLD_AND_POSITIONED_RADIO_FOR_TV
MuteGameworldAudio(b8 yesNo)  ==>>  MUTE_GAMEWORLD_AUDIO
RegisterScriptWithAudio(b8 one)  ==>>  REGISTER_SCRIPT_WITH_AUDIO
SetMobileRadioEnabledDuringGameplay(b8 onOff)  ==>>  SET_MOBILE_RADIO_ENABLED_DURING_GAMEPLAY
StopPedSpeaking(Ped ped, b8 onOff)  ==>>  STOP_PED_SPEAKING
SetCurrentMovie(char *moviefile)  ==>>  SET_CURRENT_MOVIE
DrawMovie(f32 u1, f32 u2, f32 u3, f32 u4, f32 u5, int red, int green, int blue, int alpha)  ==>>  DRAW_MOVIE
SetMovieTime(f32 time)  ==>>  SET_MOVIE_TIME
SetMovieVolume(f32 volume)  ==>>  SET_MOVIE_VOLUME
StopMovie()  ==>>  STOP_MOVIE
OverrideFreezeFlags(b8 onOff)  ==>>  OVERRIDE_FREEZE_FLAGS
SwitchStreaming(b8 onOff)  ==>>  SWITCH_STREAMING
PlayStreamFromObject(Object obj)  ==>>  PLAY_STREAM_FROM_OBJECT
PlayStreamFrontend()  ==>>  PLAY_STREAM_FRONTEND
StopStream()  ==>>  STOP_STREAM
RequestAmbientAudioBank(char *name)  ==>>  REQUEST_AMBIENT_AUDIO_BANK
PreloadStream(char *name)  ==>>  PRELOAD_STREAM
AmbientAudioBankNoLongerNeeded()  ==>>  AMBIENT_AUDIO_BANK_NO_LONGER_NEEDED
GetStreamPlaytime()  ==>>  GET_STREAM_PLAYTIME
DrawSprite(Texture texture, f32 u1, f32 u2, f32 u3, f32 u4, f32 angle, int red, int green, int blue, int alpha)  ==>>  DRAW_SPRITE
StartEndCreditsMusic()  ==>>  START_END_CREDITS_MUSIC
StopEndCreditsMusic()  ==>>  STOP_END_CREDITS_MUSIC
PlaySoundFromPed(eSound sound, ch *soundName, Ped ped)  ==>>  PLAY_SOUND_FROM_PED
PlaySoundFromObject(eSound sound, ch *soundName, Object obj)  ==>>  PLAY_SOUND_FROM_OBJECT
PlaySoundFromPosition(eSound sound, ch *soundName, f32 x, f32 y, f32 z)  ==>>  PLAY_SOUND_FROM_POSITION

// HTML WEB WHM
AddToHtmlScriptObject(int htmlobj, char *htmlcode)  ==>>  ADD_TO_HTML_SCRIPT_OBJECT
CreateHtmlScriptObject(char *objname)  ==>>  CREATE_HTML_SCRIPT_OBJECT
CreateHtmlViewport(int *htmlviewport)  ==>>  CREATE_HTML_VIEWPORT
DeleteAllHtmlScriptObjects()  ==>>  DELETE_ALL_HTML_SCRIPT_OBJECTS
DeleteHtmlScriptObject(int htmlobj)  ==>>  DELETE_HTML_SCRIPT_OBJECT
DoesWebPageExist(char *webaddress)  ==>>  DOES_WEB_PAGE_EXIST
DoesViewportExist(int htmlviewport)  ==>>  DOES_VIEWPORT_EXIST
GetScreenViewportId(int *viewportID)  ==>>  GET_SCREEN_VIEWPORT_ID
GetGameViewportId(int *viewportID)  ==>>  GET_GAME_VIEWPORT_ID
LoadWebPage(int htmlviewport, char *webaddress)  ==>>  LOAD_WEB_PAGE
ReloadWebPage(int htmlviewport)  ==>>  RELOAD_WEB_PAGE
GetWebPageHeight(int htmlviewport)  ==>>  GET_WEB_PAGE_HEIGHT
SetWebPageScroll(int htmlviewport, float scroll)  ==>>  SET_WEB_PAGE_SCROLL
GetNumberOfWebPageLinks(int htmlviewport)  ==>>  GET_NUMBER_OF_WEB_PAGE_LINKS
ch *GetWebPageLinkHref(int htmlviewport, int linkid)  ==>>  GET_WEB_PAGE_LINK_HREF
GetWebPageLinkPosn(int htmlviewport, int linkid, float *x, float *y)  ==>>  GET_WEB_PAGE_LINK_POSN
GetWebPageLinkAtPosn(int htmlviewport, float x, float y)  ==>>  GET_WEB_PAGE_LINK_AT_POSN
SetWebPageLinkActive(int htmlviewport, int linkid, b8 active)  ==>>  SET_WEB_PAGE_LINK_ACTIVE
AddFirstNCharactersOfStringToHtmlScriptObject(int htmlobj, char *str, int n)  ==>>  ADD_FIRST_N_CHARACTERS_OF_STRING_TO_HTML_SCRIPT_OBJECT
AddStringToHtmlScriptObject(int htmlobj, char *str)  ==>>  ADD_STRING_TO_HTML_SCRIPT_OBJECT
ConvertThenAddStringToHtmlScriptObject(int htmlobj, char *strgxtkey)  ==>>  CONVERT_THEN_ADD_STRING_TO_HTML_SCRIPT_OBJECT
CompareStrings(const char *str1, const char *str2)  ==>>  COMPARE_STRING       

Feel free to edit/use anything! If you have more edited natives post it here. Small code examples are welcome too.
Always respect the hard work of other coders/modders -> please make a small notation like "Thanks to Aru, Alexander Blade, Skorpro" if you use this in own mods! THANX
biggrin.gif


Hope it's helpful - have fun now smile.gif


Special thanx to:

  • Alexander Blade for ASI Loader & SCOCL natives list
  • Aru for C++ ScriptHook SDK
  • jpm1, byteMe420 and GRAX like this

AXLiberty
  • AXLiberty

    Player Hater

  • Members
  • Joined: 07 Sep 2011
  • Russia

#2

Posted 24 August 2013 - 10:49 AM

Thank you for this! smile.gif

Skorpro
  • Skorpro

    GTAholic

  • Members
  • Joined: 19 Jul 2009
  • Germany

#3

Posted 24 December 2013 - 04:17 AM Edited by Skorpro, 24 December 2013 - 04:22 AM.

Hi guys!

 

It's been a long time...

 

LetsPlayOrDy has looked for a method to set a vehicle to a position just a couple of feet in front of player.
This is a small example to do this in C++
.

Car Spawn Example:

 

CustomFiberThread.h

Scripting::Vehicle SpawnCar(Scripting::eModel model, f32 x, f32 y, f32 z, f32 h);

CustomFiberThread.cpp

...
...
...

// Global vars
Vehicle spawnCar;
f32 sx, sy, sz, sh;
b8 delcar = 0;


Scripting::Vehicle CustomFiberThread::SpawnCar(Scripting::eModel model, f32 x, f32 y, f32 z, f32 h)
{
	// Local vars
	Vehicle retVeh;
	eInteriorRoomKey carRoomKey;
	// Load model
	RequestModel(model);
	while(!HasModelLoaded(model)) { Wait(0); }
	// Spawn vehicle
	ClearArea(x, y, z, 3.01f, 1);
	Wait(0);
	CreateCar(model, x, y, z, &retVeh, true);
	GetKeyForCharInRoom(GetPlayerPed(), &carRoomKey);
	SetCarOnGroundProperly(retVeh);
	SetRoomForCarByKey(retVeh, carRoomKey);
	SetCarHeading(retVeh, h);
	MarkModelAsNoLongerNeeded(model);

	return retVeh;
}


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.
	
	Wait(2000);

	while(IsThreadAlive())		// MAIN LOOP
	{
		if (GetKeyState(116)<0)	// Press <F5> to spawn vehicle (F5 = 116)
		{
			if (delcar == 0)
			{
				GetOffsetFromCharInWorldCoords(GetPlayerPed(), 0.0f, 5.0f, 0.0f, &sx, &sy, &sz); // 5 steps from player (y coord!)
				GetCharHeading(GetPlayerPed(), &sh);
				spawnCar = SpawnCar(MODEL_ORACLE, sx, sy, sz, sh); // Check "ScriptingEnums.h" for models...
				ChangeCarColour(spawnCar, 0, 1);
				SetExtraCarColours(spawnCar, 0, 0);
				SetVehicleDirtLevel(spawnCar, 0.0f);
				WashVehicleTextures(spawnCar, 255);
				PrintStringWithLiteralStringNow("STRING", "Car spawned!", 2000, 1);
				delcar = 1;
			}
			else if (delcar == 1)
			{ 
				if ( (DoesVehicleExist(spawnCar)) && (!IsCharInCar(GetPlayerPed(), spawnCar)) ) // To delete car exit it first...
				{
					DeleteCar(&spawnCar); 
					PrintStringWithLiteralStringNow("STRING", "Car deleted!", 2000, 1);
					delcar = 0;
				}
				else PrintStringWithLiteralStringNow("STRING", "Can't delete car...", 2000, 1);
			}
			Wait(200);
		}
		Wait(0);
	}
}

Any questions? Post it here! :)

 

Merry Christmas and a Happy New Year! :D


Skorpro
  • Skorpro

    GTAholic

  • Members
  • Joined: 19 Jul 2009
  • Germany

#4

Posted 31 October 2014 - 11:57 PM Edited by Skorpro, 28 November 2014 - 11:58 PM.

Hi guys,

 

it's been a long time... but I want to bring this topic back to life... (Hope Silent - or another moderator -  can move this to GTA IV section again @Silent thanx for moving:))

 

Anyway... here is a simple way to switch the vehicle engine:

 

C++

Vehicle car;

...

GetCarCharIsUsing(GetPlayerPed(), &car);
if (t_engine == 0) 
{
	SetCarEngineOn(car, 0, 0);
	SetPetrolTankHealth(car, 0.0f);
	PrintStringWithLiteralStringNow("STRING","Engine OFF!",1200,1);
	t_engine = 1;
}
else if (t_engine == 1) 
{
	SetPetrolTankHealth(car, 1000.0f);
	SetCarEngineOn(car, 0, 0);
	Wait(500);
	SetCarEngineOn(car, 1, 1);
	PrintStringWithLiteralStringNow("STRING","Engine ON!",1200,1);
	t_engine = 0;
}

To switch the engine on it's better to use SetCarEngineOn twice (yes, you could use SetCarEngineOn(car, 1, 0) but sometimes it does not work!).

 

Have fun :)

  • jpm1 likes this

Skorpro
  • Skorpro

    GTAholic

  • Members
  • Joined: 19 Jul 2009
  • Germany

#5

Posted 01 November 2014 - 01:52 AM

Another example: SCO Loader!

 

Add this to "Scripting.h" or download my files (first post):

static u32 StartNewScript(const ch *scriptName, u32 stacksize) { return NativeInvoke::Invoke<NATIVE_START_NEW_SCRIPT, u32>(scriptName, stacksize); }

C++ SCO Loader:

void SKP::skpp(const char *printText, u32 printTime, b8 printWait)
{
	PrintStringWithLiteralStringNow("STRING", printText, printTime, 1);
	if (printWait == 1) { Wait(printTime); }
}


bool SKP::SCO_Loader(int sco_num1toX, const ch *sco_name, u32 sco_stacksize_0, b8 sco_info, u32 sco_wait)
{
	// Copy your own SCO scripts into "script.img"
	// -------------------------------------------
	// GTA IV	:	C:\Program Files (x86)\Rockstar Games\Grand Theft Auto IV\common\data\cdimages\script.img
	// TBOGT	:	C:\Program Files (x86)\Rockstar Games\EFLC\TBoGT\common\data\cdimages\script.img
	// TLAD		:	C:\Program Files (x86)\Rockstar Games\EFLC\TLAD\common\data\cdimages\script.img
	
	b8 sco_ok = 0;

	if ( (DoesScriptExist(sco_name)) && (sco_num1toX > 0) )
	{
		if (GetNumberOfInstancesOfStreamedScript(sco_name) == 0)
		{
			RequestScript(sco_name);
			while (!HasScriptLoaded(sco_name)) Wait(0);
			if (sco_num1toX == 1) { if (sco_stacksize_0 == 0) sco_stacksize_0 = 8192; }	// sco_stacksize_0 = 0 -> 8192 (first script)
			else if (sco_num1toX > 1) { if (sco_stacksize_0 == 0) sco_stacksize_0 = 1024; }	// sco_stacksize_0 = 0 -> 1024 (other scripts)
			u32 sco_scriptnum;
			sco_scriptnum = StartNewScript(sco_name, sco_stacksize_0);
			MarkScriptAsNoLongerNeeded(sco_name);
			if (sco_info == 1) 
			{
				char infotext[64];
				strncpy_s(infotext, "~COL_NET_3~'~COL_NET_4~ ", 26);
				strncat_s(infotext, sco_name, strlen(sco_name));
				strncat_s(infotext, " ~COL_NET_3~' loaded!", 22);
				skpp(infotext, 2000, 0);
			}
			sco_ok = 1;
		}
		else skpp("SCO Script already loaded!", 3000, 0);
	}
	else skpp("Unknown SCO Script or Number!", 3000, 0);

	if (sco_wait > 0) Wait(sco_wait);

	return sco_ok;
}

Hint: Never simply copy & paste! You must adapt this code to your own.

 

 

Usage:

SCO_Loader(1, "z_heliblock", 0, 1, 1000);
SCO_Loader(2, "z_traffic", 0, 1, 1000);
SCO_Loader(3, "z_worldprops", 0, 1, 1000);
SCO_Loader(4, "z_zombgen", 0, 1, 1000);

Note: All my scripts are for free use! Be fair: Please make a small credit like "Thanx to Skorpro" if you want to use them! Thanx :)

  • AgentWD40 and GRAX like this

tall70
  • tall70

    Player Hater

  • Members
  • Joined: 03 Jan 2009

#6

Posted 27 November 2014 - 05:57 AM Edited by tall70, 27 November 2014 - 05:59 AM.

Uhhh, little too much for me to get just quickly involved in, i was hopping for little simpler editing. I'm using almost all your scripts since it doesn't bug rain effects without use of ScriptHookDotNet, thanks for all of it. But those tutorials... they very nice for people with deeper interest an knowledge which i have total zero. I better stick with things i have some experience already before i get whole weekends tied up with another hobby.


stef538
  • stef538

    It's just me, going 88 MPH.

  • Members
  • Joined: 06 Oct 2012
  • Netherlands

#7

Posted 27 November 2014 - 02:22 PM

how do we use this native : GetVehicleDirtLevel

 

I tried it this way : 

GetVehicleDirtLevel(thecurrentvehicle, dirtyness);

 

thecurrentvehicle is the vehicle we currently use, and dirtyness is a float, but whenever I try to echo the value of dirtyness it always returns with a 0.


jpm1
  • jpm1

    Vice city citizen

  • Members
  • Joined: 26 Sep 2005
  • European-Union

#8

Posted 27 November 2014 - 03:39 PM Edited by jpm1, 27 November 2014 - 03:42 PM.

always happy when i find a gold mine :colgate: . You should upload your engine off to some downloads sites i think it would be successful


LetsPlayOrDy
  • LetsPlayOrDy

    So fast you'll freak!

  • Members
  • Joined: 24 Aug 2013
  • United-States

#9

Posted 28 November 2014 - 04:34 PM Edited by LetsPlayOrDy, 28 November 2014 - 11:57 PM.

how do we use this native : GetVehicleDirtLevel
 
I tried it this way : 

GetVehicleDirtLevel(thecurrentvehicle, dirtyness);
 
thecurrentvehicle is the vehicle we currently use, and dirtyness is a float, but whenever I try to echo the value of dirtyness it always returns with a 0.

GET_VEHICLE_DIRT_LEVEL(Vehicle vehicle, float* pIntensity);

f32 dirtLevel;
GetVehicleDirtLevel(yourVeh, &dirtLevel);

Is this how you are using it?

stef538
  • stef538

    It's just me, going 88 MPH.

  • Members
  • Joined: 06 Oct 2012
  • Netherlands

#10

Posted 28 November 2014 - 09:59 PM

yeah..


Skorpro
  • Skorpro

    GTAholic

  • Members
  • Joined: 19 Jul 2009
  • Germany

#11

Posted 28 November 2014 - 11:38 PM

@stef538

Your code is fine! But you have to use DisplayTextWithFloat to show float values :)

f32 fDirt = 0.0f;
Vehicle veh;


while(IsThreadAlive())
{
	if (IsCharInAnyCar(GetPlayerPed()))
	{
		GetCarCharIsUsing(GetPlayerPed(), &veh);
		GetVehicleDirtLevel(veh, &fDirt);
		DisplayTextWithFloat(0.5f, 0.9f, "NUMBER", fDirt, 3); // decimal places = 3
	}

	Wait(0);
}
  • stef538 likes this

Skorpro
  • Skorpro

    GTAholic

  • Members
  • Joined: 19 Jul 2009
  • Germany

#12

Posted 28 November 2014 - 11:52 PM

Uhhh, little too much for me to get just quickly involved in, i was hopping for little simpler editing. I'm using almost all your scripts since it doesn't bug rain effects without use of ScriptHookDotNet, thanks for all of it. But those tutorials... they very nice for people with deeper interest an knowledge which i have total zero. I better stick with things i have some experience already before i get whole weekends tied up with another hobby.

Thanx :D

Believe me it's easier than it looks. But I have the same problem: Too many ideas/hobbies and not enough time... ;)

 

 

 

always happy when i find a gold mine :colgate: . You should upload your engine off to some downloads sites i think it would be successful

You're welcome :) Maybe I will make a Mods Pack Vol.2 (with some 'unpublished' mods) before GTA V comes out.


Skorpro
  • Skorpro

    GTAholic

  • Members
  • Joined: 19 Jul 2009
  • Germany

#13

Posted 29 November 2014 - 12:35 AM

@DaBOSS54320 (referring to: "how to disable a vehicle from spawning in traffic")

 

How to suppress a vehicle:

// Global
Vehicle veh;
eModel model;

. . .


while(IsThreadAlive())
{
	if (IsCharInAnyCar(GetPlayerPed()))
	{
		GetCarCharIsUsing(GetPlayerPed(), &veh);
		GetCarModel(veh, &model);
		SuppressCarModel(model);
	}
	else DontSuppressCarModel(model);

	Wait(0);
}

Note:

Add this to "Scripting.h" or download my files (first post):

static void SuppressCarModel(eModel model) { NativeInvoke::Invoke<NATIVE_SUPPRESS_CAR_MODEL, ScriptVoid>(model); }
static void DontSuppressCarModel(eModel carmodel) { NativeInvoke::Invoke<NATIVE_DONT_SUPPRESS_CAR_MODEL, ScriptVoid>(carmodel); }
  • AgentWD40 likes this

stef538
  • stef538

    It's just me, going 88 MPH.

  • Members
  • Joined: 06 Oct 2012
  • Netherlands

#14

Posted 29 November 2014 - 10:26 AM Edited by stef538, 29 November 2014 - 11:39 AM.

 

@stef538

Your code is fine! But you have to use DisplayTextWithFloat to show float values :)

f32 fDirt = 0.0f;
Vehicle veh;


while(IsThreadAlive())
{
	if (IsCharInAnyCar(GetPlayerPed()))
	{
		GetCarCharIsUsing(GetPlayerPed(), &veh);
		GetVehicleDirtLevel(veh, &fDirt);
		DisplayTextWithFloat(0.5f, 0.9f, "NUMBER", fDirt, 3); // decimal places = 3
	}

	Wait(0);
}

 

Thank you!! But whenever I use the GET_VEHICLE_DIRT_LEVEL it gives me an error... "Attempted to read or write protected memory"


Skorpro
  • Skorpro

    GTAholic

  • Members
  • Joined: 19 Jul 2009
  • Germany

#15

Posted 30 November 2014 - 10:34 AM

Thank you!! But whenever I use the GET_VEHICLE_DIRT_LEVEL it gives me an error... "Attempted to read or write protected memory"

I don't know why you got this error?!

 

I checked it in SCO too. The script works!

#define PP GetPlayerPed()
Vehicle veh;
float fDirt;

. . .

if (IS_CHAR_IN_ANY_CAR(PP))
{
	GET_CAR_CHAR_IS_USING(PP, &veh);
	GET_VEHICLE_DIRT_LEVEL(veh, &fDirt);
	DISPLAY_TEXT_WITH_FLOAT(0.5, 0.9, "NUMBER", fDirt, 3);
}

Hint: If you use .Net don't call this native like this "GTA.Native.Function.Call("GET_VEHICLE_DIRT_LEVEL", veh, fDirt);"! Better use Hazard's classes:

// Taken from Hazard's Vehicle.cpp!
float Vehicle::Dirtyness::get()
{
	NON_EXISTING_CHECK(0.0f);
	f32 res;
	Scripting::GetVehicleDirtLevel(pHandle,&res);
	return res;
}
void Vehicle::Dirtyness::set(float value)
{
	NON_EXISTING_CHECK();
	Scripting::SetVehicleDirtLevel(pHandle,value);
}

Hope it works for you :)

 

  • stef538 likes this

rodd1981
  • rodd1981

    Player Hater

  • Members
  • Joined: 24 Dec 2012
  • Brazil

#16

Posted 03 December 2014 - 03:58 AM

Another example: SCO Loader!

 

Add this to "Scripting.h" or download my files (first post):

static u32 StartNewScript(const ch *scriptName, u32 stacksize) { return NativeInvoke::Invoke<NATIVE_START_NEW_SCRIPT, u32>(scriptName, stacksize); }

C++ SCO Loader:


 

Usage:

SCO_Loader(1, "z_heliblock", 0, 1, 1000);
SCO_Loader(2, "z_traffic", 0, 1, 1000);
SCO_Loader(3, "z_worldprops", 0, 1, 1000);
SCO_Loader(4, "z_zombgen", 0, 1, 1000);

Note: All my scripts are for free use! Be fair: Please make a small credit like "Thanx to Skorpro" if you want to use them! Thanx :)

 

@Skorpro

 

I am a real fan of your work. I've used your bombmod on a SCO mission that was released for PS3 back in 2012 (see video below - and of course, I've given you the credit for the mod in the video):

 

https://www.youtube....h?v=3GejxqYjyKw

 

I'm currently working on a bigger project now (VC++ app to build your own GTA missions) and I am desperately looking for some help with SCO/.NET

 

I usually code only in native SCO because I started doing mods on PS3 (so I don't have skills to code script hook stuff). Basically, I want to know if it's possible to create a ASI/DLL script to load external SCO files (like the DLL ones that are loaded via script hook console on /scripts dir). That would boost my dev work a lot (and of course would be f**kin' great, lol).

 

Right now I have to rebuild script.img on OpenIV everytime I do changes on my C SCO project (and load up the game afterwards). That takes me around 5 mins (I'd love to speed things up).

 

Let me know if you have any ideas in mind.

 

Thx,

 

- rodd1981


LetsPlayOrDy
  • LetsPlayOrDy

    So fast you'll freak!

  • Members
  • Joined: 24 Aug 2013
  • United-States

#17

Posted 03 December 2014 - 09:12 PM

Basically, I want to know if it's possible to create a ASI/DLL script to load external SCO files (like the DLL ones that are loaded via script hook console on /scripts dir). That would boost my dev work a lot (and of course would be f**kin' great, lol).

I don't think that would be possible

  • rodd1981 likes this

Skorpro
  • Skorpro

    GTAholic

  • Members
  • Joined: 19 Jul 2009
  • Germany

#18

Posted 04 December 2014 - 03:36 PM

I am a real fan of your work.

Thanx :D

 

I usually code only in native SCO because I started doing mods on PS3 (so I don't have skills to code script hook stuff). Basically, I want to know if it's possible to create a ASI/DLL script to load external SCO files (like the DLL ones that are loaded via script hook console on /scripts dir). That would boost my dev work a lot (and of course would be f**kin' great, lol).

 

Right now I have to rebuild script.img on OpenIV everytime I do changes on my C SCO project (and load up the game afterwards). That takes me around 5 mins (I'd love to speed things up).

AFAIK it's impossible, because SCO scripts must be included in a IMG file, otherwise GTA couldn't find them!

Example: The "DoesScriptExist" native checks the known IMG files.

 

 


Skorpro
  • Skorpro

    GTAholic

  • Members
  • Joined: 19 Jul 2009
  • Germany

#19

Posted 12 December 2014 - 05:06 PM

@stef538 (referring to: "Convert GTA IV model hash to string")

 

Here is an example how to convert a model string to a hash string:

char cHash[16];

...

char *SKP::ModelStringToHashString(char *key, int IHBU)
{
	if (IHBU == 0) { _ltoa_s(GetHashKey(key), cHash, 10); }	// Int=10
	if (IHBU == 1) { _ltoa_s(GetHashKey(key), cHash, 16); }	// Hex=16
	if (IHBU == 2) { _ltoa_s(GetHashKey(key), cHash, 2); }	// Bin=2
	if (IHBU == 3) { _ultoa_s(GetHashKey(key), cHash, 10); }// Unsigned Int=10

	return cHash;
}

Here is the native to convert a model string to a hash:

u32 GetHashKey(const ch *value) // native
// or
eModel GetModelHash(const ch *name) // this is NOT a 'regular native' - this function is done by Aru!
  • stef538 likes this

Skorpro
  • Skorpro

    GTAholic

  • Members
  • Joined: 19 Jul 2009
  • Germany

#20

Posted 23 January 2015 - 11:33 PM

Hi guys,

 

here are my file/INI functions:

 

C++

// INI/FILE FUNCTIONS

#define INI_Name "./test mod.ini"


// STRING
char* SKP::SkorproReadString(char* Section, char* Key, const char* DefaultString)
{
	char* Result = new char[255];
	memset(Result, 0x00, 255);
	GetPrivateProfileStringA(Section, Key, DefaultString, Result, 255, INI_Name); 
	return Result;
}

void SKP::SkorproWriteString(char* Section, char* Key, const char* ValueString)
{
	WritePrivateProfileStringA(Section, Key, ValueString, INI_Name);
}


// INT
int SKP::SkorproReadInteger(char* Section, char* Key, int DefaultInt)
{
	 int Result = GetPrivateProfileIntA(Section,  Key, DefaultInt, INI_Name); 
	 return Result;
}

void SKP::SkorproWriteInteger(char* Section, char* Key, int ValueInt, b8 DecHex)
{
	char tmpValue[255];
	if (DecHex == 0) { sprintf_s(tmpValue, 255, "%d", ValueInt); } // %d = DEC
	if (DecHex == 1) { sprintf_s(tmpValue, 255, "%x", ValueInt); } // %x = HEX
	WritePrivateProfileStringA(Section, Key, tmpValue, INI_Name); 
}


// FLOAT
float SKP::SkorproReadFloat(char* szSection, char* szKey, float DefaultFloat)
{
	char szResult[255];
	char szDefault[255];
	double dResult;
	float fResult;
	sprintf_s(szDefault, "%f",DefaultFloat);
	GetPrivateProfileStringA(szSection,  szKey, szDefault, szResult, 255, INI_Name); 
	dResult =  atof(szResult);
	fResult = (f32) dResult;
	return fResult;
}

void SKP::SkorproWriteFloat(char* szSection, char* szKey, float ValueFloat, int Nachkommastellen)
{
	char szValue[255];
	if (Nachkommastellen <= 1) sprintf_s(szValue, "%.1f", ValueFloat);
	else if (Nachkommastellen == 2) sprintf_s(szValue, "%.2f", ValueFloat);
	else if (Nachkommastellen == 3) sprintf_s(szValue, "%.3f", ValueFloat);
	else if (Nachkommastellen == 4) sprintf_s(szValue, "%.4f", ValueFloat);
	else if (Nachkommastellen == 5) sprintf_s(szValue, "%.5f", ValueFloat);
	else if (Nachkommastellen == 6) sprintf_s(szValue, "%.6f", ValueFloat);
	else if (Nachkommastellen >= 7) sprintf_s(szValue, "%.7f", ValueFloat);
	WritePrivateProfileStringA(szSection, szKey, szValue, INI_Name); 
}


// Backup
void SKP::SkorproBackupINI()
{
	char BackupINI[64];
	strncpy_s(BackupINI, INI_Name, 54);
	strncat_s(BackupINI, ".backup", 10);
	CopyFileA(INI_Name, BackupINI, false); // "false" überschreibt "BackupINI", falls diese existiert!
}

Have fun :)

  • GRAX likes this

GRAX
  • GRAX

    c++ beginner

  • Members
  • Joined: 27 Jan 2015
  • European-Union

#21

Posted 27 January 2015 - 03:11 PM

wow dude thank you for this thread!!!
  • Skorpro likes this

Skorpro
  • Skorpro

    GTAholic

  • Members
  • Joined: 19 Jul 2009
  • Germany

#22

Posted 02 February 2015 - 05:40 AM

wow dude thank you for this thread!!!

You're welcome :)

Any questions? Post it here :)


Skorpro
  • Skorpro

    GTAholic

  • Members
  • Joined: 19 Jul 2009
  • Germany

#23

Posted 02 February 2015 - 08:03 AM

How to read the carcols.dat

 

Hi,

@ALL & @ClareXoBearrx3   (referring to: "C++ getline()")

 

Here is a way (there are many others in C++ ;)) how to read particular parts of a line taken from a file (here the carcols.dat as example!):

// GTA 4 & TLAD = 134 colors // TBOGT = 137 colors!
#define MAX_COLORS 137
ifstream iFile;
string strLine;
int col_temp[3] = { 999, 999, 999 };
int col_array[MAX_COLORS][3];
int col_count = 0;
Vehicle veh;
u32 uCol[4];


// . . .


bool SKP::ColorFile()
{
   bool bOk = 0;

   iFile.open("./common/data/carcols.dat", ios::in);

   if (iFile.fail() || iFile.bad())
   {
      skpp("Carcols.dat READ ERROR!", 5000, 0);
   }
   else
   {
      iFile.seekg(0L, ios::beg);

      while (!iFile.eof())
      {
         getline(iFile, strLine);
         if (strLine.find("col") == 0) // find 'col' and start reading!
         {
            while (true)
            {
               getline(iFile, strLine);

               stringstream ss(strLine);
               for (int i = 0; i < 3; i++) col_temp[i] = 999;
               string token;
               int iToken = 0;

               while (getline(ss, token, ','))
               {
                  col_temp[iToken] = atoi(token.c_str());
                  iToken++;
                  if (iToken == 3) break;
               }
               ss.clear();

               // Check
               if (col_temp[0] != 999 && col_temp[1] != 999 && col_temp[2] != 999)
               {
                  for (int i = 0; i < 3; i++) col_array[col_count][i] = col_temp[i];                  
                  col_count++;
               }

               if (strLine.find("end") == 0) break; // read until 'end'!
            }
         }
      }
      bOk = 1;
   }
   iFile.close();

   return bOk;
}


// . . .


void SKP::RunScript()
{

   // read carcols.dat
   ColorFile();
   
   
   // . . .

   
   while(IsThreadAlive())
   {
      // . . .
      
      if (IsCharInAnyCar(GetPlayerPed()))
      {
         GetCarCharIsUsing(GetPlayerPed(), &veh);
         GetCarColours(veh, &uCol[0], &uCol[1]);
         GetExtraCarColours(veh, &uCol[2], &uCol[3]);
         
         SkorproText("COLOR 1", 0.40f, 0.95f, 0, col_array[uCol[0]][0], col_array[uCol[0]][1], col_array[uCol[0]][2]);
         SkorproText("COLOR 2", 0.47f, 0.95f, 0, col_array[uCol[1]][0], col_array[uCol[1]][1], col_array[uCol[1]][2]);
         SkorproText("COLOR 3", 0.54f, 0.95f, 0, col_array[uCol[2]][0], col_array[uCol[2]][1], col_array[uCol[2]][2]);
         SkorproText("COLOR 4", 0.61f, 0.95f, 0, col_array[uCol[3]][0], col_array[uCol[3]][1], col_array[uCol[3]][2]);
      }
      
      Wait(0);
   }
}

Note: All my scripts are for free use! Be fair: Please make a small credit like "Thanx to Skorpro" if you want to use them! Thanx :D

Hint: Never simply copy & paste! You must adapt this code to your own.

  • GRAX likes this

GRAX
  • GRAX

    c++ beginner

  • Members
  • Joined: 27 Jan 2015
  • European-Union

#24

Posted 05 February 2015 - 02:41 PM

hi skorpro!
could you post your "SkorproText" function? im still a c++ noob.
TXL!

Skorpro
  • Skorpro

    GTAholic

  • Members
  • Joined: 19 Jul 2009
  • Germany

#25

Posted 07 February 2015 - 09:58 AM

How to play MP3 with C++ ScriptHook:   (referring to: "(C++) Playing External Sound")

#include <windows.h>
#include <MMSystem.h>
#pragma comment(lib, "winmm.lib")


. . . .


mciSendString(TEXT("open Test.mp3"),NULL,0,0);
mciSendString(TEXT("play Test.mp3 repeat"),NULL,0,0);
mciSendString(TEXT("setaudio Test.mp3 output volume to 500"),NULL,0,0);  // Volume = 500 (0 - 1000)

Have fun :D

  • leftas likes this

Skorpro
  • Skorpro

    GTAholic

  • Members
  • Joined: 19 Jul 2009
  • Germany

#26

Posted 07 February 2015 - 10:19 AM

could you post your "SkorproText" function? im still a c++ noob.

Here you are :)

void SKP::SkorproText(const char *text, f32 x, f32 y, int iFont, int iRed, int iGreen, int iBlue)
{
	SetTextFont( (eTextFont) iFont); // 0=SMOOTH_DEFAULT / 1=LED / 2=FAT (Nicht nutzen!) / 3=UNKNOWN (Nicht nutzen!) / 4=SMOOTH_ALT
	SetTextBackground(0);
	SetTextScale(0.22f, 0.27f);
	SetTextColour(iRed, iGreen, iBlue, 255);
	SetTextRightJustify(0);
	SetTextDropshadow(0, 255, 255, 255, 255);
	DisplayTextWithLiteralString(x, y, "STRING", text);
}
  • GRAX likes this

yoloman
  • yoloman

    Crackhead

  • Members
  • Joined: 21 Jul 2014
  • None

#27

Posted 07 February 2015 - 01:27 PM Edited by yoloman, 08 February 2015 - 10:48 PM.

Another example: SCO Loader!
 
Add this to "Scripting.h" or download my files (first post):

static u32 StartNewScript(const ch *scriptName, u32 stacksize) { return NativeInvoke::Invoke<NATIVE_START_NEW_SCRIPT, u32>(scriptName, stacksize); }
C++ SCO Loader:
void SKP::skpp(const char *printText, u32 printTime, b8 printWait)
{
	PrintStringWithLiteralStringNow("STRING", printText, printTime, 1);
	if (printWait == 1) { Wait(printTime); }
}


bool SKP::SCO_Loader(int sco_num1toX, const ch *sco_name, u32 sco_stacksize_0, b8 sco_info, u32 sco_wait)
{
	// Copy your own SCO scripts into "script.img"
	// -------------------------------------------
	// GTA IV	:	C:\Program Files (x86)\Rockstar Games\Grand Theft Auto IV\common\data\cdimages\script.img
	// TBOGT	:	C:\Program Files (x86)\Rockstar Games\EFLC\TBoGT\common\data\cdimages\script.img
	// TLAD		:	C:\Program Files (x86)\Rockstar Games\EFLC\TLAD\common\data\cdimages\script.img
	
	b8 sco_ok = 0;

	if ( (DoesScriptExist(sco_name)) && (sco_num1toX > 0) )
	{
		if (GetNumberOfInstancesOfStreamedScript(sco_name) == 0)
		{
			RequestScript(sco_name);
			while (!HasScriptLoaded(sco_name)) Wait(0);
			if (sco_num1toX == 1) { if (sco_stacksize_0 == 0) sco_stacksize_0 = 8192; }	// sco_stacksize_0 = 0 -> 8192 (first script)
			else if (sco_num1toX > 1) { if (sco_stacksize_0 == 0) sco_stacksize_0 = 1024; }	// sco_stacksize_0 = 0 -> 1024 (other scripts)
			u32 sco_scriptnum;
			sco_scriptnum = StartNewScript(sco_name, sco_stacksize_0);
			MarkScriptAsNoLongerNeeded(sco_name);
			if (sco_info == 1) 
			{
				char infotext[64];
				strncpy_s(infotext, "~COL_NET_3~'~COL_NET_4~ ", 26);
				strncat_s(infotext, sco_name, strlen(sco_name));
				strncat_s(infotext, " ~COL_NET_3~' loaded!", 22);
				skpp(infotext, 2000, 0);
			}
			sco_ok = 1;
		}
		else skpp("SCO Script already loaded!", 3000, 0);
	}
	else skpp("Unknown SCO Script or Number!", 3000, 0);

	if (sco_wait > 0) Wait(sco_wait);

	return sco_ok;
}
Hint: Never simply copy & paste! You must adapt this code to your own.
 
 
Usage:
SCO_Loader(1, "z_heliblock", 0, 1, 1000);
SCO_Loader(2, "z_traffic", 0, 1, 1000);
SCO_Loader(3, "z_worldprops", 0, 1, 1000);
SCO_Loader(4, "z_zombgen", 0, 1, 1000);
Note: All my scripts are for free use! Be fair: Please make a small credit like "Thanx to Skorpro" if you want to use them! Thanx :)
So I have a few questions about this. 
 
1. What to do with this Sco Loader code? Should I do it like in the instructions from the first post? 
2. (Never simply copy & paste) What should I edit or change in the code? Maybe something like sco_name and sco_stacksize?
3.And where to add the last code (with these SCO_Loader(1, z_heliblock,...))?
 
sry for bad english :D

GRAX
  • GRAX

    c++ beginner

  • Members
  • Joined: 27 Jan 2015
  • European-Union

#28

Posted 07 February 2015 - 09:49 PM

Here you are :)

thank you again!

ceedj
  • ceedj

    PEDS Creator

  • Feroci
  • Joined: 21 May 2005
  • United-States

#29

Posted 20 February 2015 - 10:38 PM

Hey Skorp, quickie question, what was the difference between using CustomThread and CustomFiberThread again? Is it the hash conversion? I have some ideas for rebuilding my studios code, but want to test on IV first.

 

Nice work here!


NTAuthority
  • NTAuthority

    hell, no, tunnel, no

  • Feroci
  • Joined: 09 Sep 2008
  • European-Union
  • Best Conversion 2014 [ViIV for GTANY]
    Most Knowledgeable [Tech] 2013
    Best Map 2013 [ViceCityStories PC Edition]
    Contribution Award [Mods]

#30

Posted 21 February 2015 - 04:41 AM

Hey Skorp, quickie question, what was the difference between using CustomThread and CustomFiberThread again? Is it the hash conversion? I have some ideas for rebuilding my studios code, but want to test on IV first.
 
Nice work here!

FiberThread allows one to use an equivalent of the native scripting 'WAIT' command to suspend the 'script', whereas the regular thread only exposes a tick method.
  • ceedj likes this




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users