Thread: ScriptHook
View Single Post
Old 04-06-2009   #3
Leito
Registered User
Junior Member
 
Leito's Avatar
 
Join Date: Jan 2009
Posts: 54
Leito will become famous soon enoughLeito will become famous soon enoughLeito will become famous soon enoughLeito will become famous soon enoughLeito will become famous soon enoughLeito will become famous soon enough
CustomFiberThread.cpp

Quote:
#include "CustomFiberThread.h"
#include "Scripting.h"
#include "../ScriptHook/Log.h"

#include <windows.h>

// Pull in all our scripting functions/types
using namespace Scripting;

CustomFiberThread::CustomFiberThread()
{
SetName("CustomFiberThread");
}

// The real script
int m_State=0;
int StateAnim = 1;
int StateDefault = 0;
f32 speed = 4.0f;
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.

while(IsThreadAlive())
{
if ((GetAsyncKeyState(VK_F1) & 1) != 0)
{
LogInfo("animation");
RequestAnims("amb@smoking_spliff");
m_State = StateAnim;
}

if(m_State == 1){
if (HaveAnimsLoaded("amb@smoking_spliff")){
Ped ped;
Player playerIndex = ConvertIntToPlayerIndex(GetPlayerId());
GetPlayerChar(playerIndex, &ped);
TaskPlayAnim(ped,"create_spliff","amb@smoking_spli ff",speed,0,0,0,0,-1);
m_State = StateDefault;
}
break;
}

// Call Wait() so we can process other scripts/game code
// You must call Wait(...) in your loop code for a fiber thread!
Wait(100);

}


}
Scripting.h

Quote:
#pragma once

#include "../ScriptHook/Scripting.h"

namespace Scripting

TaskPlayAnim();
{

static void TaskPlayAnim(Ped ped, const ch *animSequence, const ch *animName, f32 speed, int loop, f32 x, f32 y, f32 z, int ms) { NativeInvoke::Invoke<scriptVoid>("TASK_PLAY_ANIM", ped, animSequence, animName, speed, loop, x, y, z, ms); }

}
Error

Quote:
1>------ Build started: Project: SampleCustomFiber, Configuration: Debug Win32 ------
1>Compiling...
1>CustomFiberThread.cpp
1>d:\users\leito\desktop\gta iv - pliki\gta iv - mody i pliki\aru c++\samplecustomfiber\scripting.h(7) : error C2061: syntax error : identifier 'TaskPlayAnim'
1>d:\users\leito\desktop\gta iv - pliki\gta iv - mody i pliki\aru c++\samplecustomfiber\scripting.h(8) : error C2447: '{' : missing function header (old-style formal list?)
1>d:\users\leito\desktop\gta iv - pliki\gta iv - mody i pliki\aru c++\samplecustomfiber\customfiberthread.cpp(39) : error C3861: 'TaskPlayAnim': identifier not found
1>Build log was saved at "file://d:\Users\Leito\Desktop\GTA IV - Pliki\GTA IV - Mody i Pliki\aru C++\SampleCustomFiber\Debug\BuildLog.htm"
1>SampleCustomFiber - 3 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 2 up-to-date, 0 skipped ==========
__________________
My nick on YT - RyderPL
Leito is offline   Reply With Quote