View Full Version : ScriptHook
Leito
04-06-2009, 08:43 AM
Hi. My next topic about animation xD But I else learn and i dont know how to make any animation when i press F10. I found script, but i have error. Anybody help me? This script is in LogInfo("animation");.
#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");
}
// 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);
}
// 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.
while(IsThreadAlive())
{
if ((GetAsyncKeyState(VK_F5) & 1) != 0)
{
LogInfo("Spawning a random car");
Vehicle vehicle;
u32 modelHash;
ScriptAny unknown;
f32 x,y,z;
GetCharCoordinates(GetPlayerPed(), &x, &y, &z);
GetRandomCarModelInMemory(1, &modelHash, &unknown);
CreateCar(modelHash, x, y, z, &vehicle, true);
}
else if ((GetAsyncKeyState(VK_F6) & 1) != 0)
{
LogInfo("Granting player $1000");
AddScore(GetPlayer(), 1000);
}
else if ((GetAsyncKeyState(VK_F7) & 1) != 0)
{
LogInfo("Requested a MODEL_BANSHEE spawn");
SpawnCar(MODEL_BANSHEE);
}
else if ((GetAsyncKeyState(VK_F8) & 1) != 0)
{
LogInfo("Changing the player skin");
ChangePlayerSkin(MODEL_IG_JOHNNYBIKER);
}
else if ((GetAsyncKeyState(VK_F9) & 1) != 0)
{
LogInfo("Changing the player skin back to Niko's");
ChangePlayerSkin(MODEL_PLAYER);
}
else if ((GetAsyncKeyState(VK_F10) & 1) != 0)
{
LogInfo("animation");
m_animName="amb@smoking_spliff";
m_animSequence="create_spliff";
speed=4.0f;
RequestAnims(m_animName);
anim=1;
m_State = StateAnim;
}
case StateAnim:
{
else if (HaveAnimsLoaded(m_animName))
{
Ped ped;
Player playerIndex = ConvertIntToPlayerIndex(GetPlayerId());
GetPlayerChar(playerIndex, &ped);
TaskPlayAnim(ped,m_animSequence,m_animName,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);
}
}
rappo
04-06-2009, 12:59 PM
Can you paste the actual error that you're getting?
Leito
04-06-2009, 01:55 PM
CustomFiberThread.cpp
#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_spliff",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
#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
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 ==========
rappo
04-06-2009, 03:00 PM
Your Scripting.h file should look like this:
#pragma once
#include "../ScriptHook/Scripting.h"
namespace Scripting {
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); }
}
The syntax you put isn't correct, so change it to the one I gave above and see if that helps. If not, post the new error it gives!
Leito
04-07-2009, 08:20 AM
Thx, but I was have to added to NativeInvoke::Invoke <ScriptVoid>, because I've got error - "error C2660: 'NativeInvoke::Invoke' : function does not take 10 arguments" I was builded solution and I was copy to game. I was pressed F12, but he don't do anything animation.
rappo
04-07-2009, 10:28 AM
Okay I compiled and ran my own version, and it works. I think the main problem is that you had TaskPlayAnim(..."spli ff") with a space between the spli and ff... you have to make that "spliff" and it might work. But here's my version, and it's working (the only thing is, there's no spliff model, just the smoke, but you have to code in RequestModel if you want the actual thing to appear):
CustomFiberThread.h
#pragma once
#include "../ScriptHook/NativeFiberThread.h"
#include "../ScriptHook/ScriptingEnums.h"
#include "../ScriptHook/ScriptingTypes.h"
class CustomFiberThread : public NativeFiberThread {
private:
Scripting::Player GetPlayer();
Scripting::Ped GetPlayerPed();
b8 playSpliff;
protected:
void RunScript();
void setDefaultValues();
void Start();
public:
CustomFiberThread();
};
Scripting.h
#pragma once
#include "../ScriptHook/Scripting.h"
namespace Scripting {
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); }
}
CustomFiberThread.cpp
#include "CustomFiberThread.h"
#include "Scripting.h"
#include "../ScriptHook/Log.h"
#include <windows.h>
using namespace Scripting;
CustomFiberThread::CustomFiberThread(){
SetName("Animation");
setDefaultValues();
}
Player CustomFiberThread::GetPlayer() {
Player playerIndex = ConvertIntToPlayerIndex(GetPlayerId());
return playerIndex;
}
Scripting::Ped CustomFiberThread::GetPlayerPed() {
Ped ped;
GetPlayerChar(GetPlayer(), &ped);
return ped;
}
void CustomFiberThread::setDefaultValues() {
playSpliff = false;
}
void CustomFiberThread::Start() {
setDefaultValues();
NativeThread::Start();
}
void CustomFiberThread::RunScript() {
while(IsThreadAlive()) {
if((GetAsyncKeyState(VK_F12) && 1) != 0) {
LogInfo("Requesting spliff animation");
RequestAnims("amb@smoking_spliff");
playSpliff = true;
}
if(playSpliff && HaveAnimsLoaded("amb@smoking_spliff")) {
LogInfo("Playing spliff animation");
TaskPlayAnim(GetPlayerPed(), "create_spliff", "amb@smoking_spliff", 4.0f, 0, 0, 0, 0, -1);
playSpliff = false;
}
Wait(100);
}
}
Leito
04-07-2009, 11:12 AM
wow! rappo, very, very thanks, it works :) But I don't know why i have to change #include in CustomFiberThread.cpp on #include <windows.h>. It depends on version? I've got Visual C++ 2008, and Scripthook 0.2.3. I thanks one more time.
edit: Last question. How to make script to other animation, example medic.wad, or telescope_idles.wad? I tryed change Spliff on Idles, but don't run.
rappo
04-07-2009, 01:59 PM
wow! rappo, very, very thanks, it works :) But I don't know why i have to change #include in CustomFiberThread.cpp on #include <windows.h>. It depends on version? I've got Visual C++ 2008, and Scripthook 0.2.3. I thanks one more time.
sorry that was vBulletin that took it out - I fixed it, youre right it has to be there! I use the same versions as you :D
And for changing the animation, the best thing to do is use SparkIV to look at other scripts. Since the names of the animations and groups aren't the same as the .wad file, you need to look them up in scripts. You use SparkIV to open the /common/data/cdimages/script.img file, and in there you will see .sco files. Open up the .sco file you want and search around for "TaskPlayAnim" and you'll see the code that you need.
For an example, I looked at Brian's script and it gave me names that I put in the animation (I also changed playSpliff variable to playAnim). This animation makes Niko stand and wave:
void CustomFiberThread::RunScript() {
while(IsThreadAlive()) {
if((GetAsyncKeyState(VK_F12) && 1) != 0) {
LogInfo("Requesting animation");
RequestAnims("missbrian_1");
playAnim = true;
}
if(playAnim && HaveAnimsLoaded("missbrian_1")) {
LogInfo("Playing animation");
TaskPlayAnim(GetPlayerPed(), "friendly_idle", "missbrian_1", 4.0f, 0, 0, 0, 0, -1);
playAnim = false;
}
Wait(100);
}
}
If you want to find something specific, you have to think where it might be. Like if you want something related to taxis, you can check "taxi.sco". If you want omething that you remember was in a mission, you can find the mission script.
Leito
04-07-2009, 02:55 PM
O thank you :) Everything act, if I didn't know something, I will write here, but now thank you ^^
Leito
05-25-2009, 03:05 PM
Hi again. I've got the problem. I have now Windows7 and same Visual C++, but in GTA IV patch 1.3. I pasted your scripts, and when i want to save, i've got errors ;c rappo, what's going on?
PS. sry for double.
1>------ Build started: Project: SampleCustom, Configuration: Debug Win32 ------
1>Compiling...
2>------ Build started: Project: SampleCustomFiber, Configuration: Debug Win32 ------
2>Compiling...
1>CustomThread.cpp
2>CustomFiberThread.cpp
1>c:\gta iv - pliki\gta iv - mody i pliki\aru c++\gtaivscripthook_0.2.3\scripthook\scripting.h(6 ) : error C2065: 'Ped' : undeclared identifier
1>c:\gta iv - pliki\gta iv - mody i pliki\aru c++\gtaivscripthook_0.2.3\scripthook\scripting.h(6 ) : error C2146: syntax error : missing ')' before identifier 'ped'
1>c:\gta iv - pliki\gta iv - mody i pliki\aru c++\gtaivscripthook_0.2.3\scripthook\scripting.h(6 ) : error C2182: 'TaskPlayAnim' : illegal use of type 'void'
1>c:\gta iv - pliki\gta iv - mody i pliki\aru c++\gtaivscripthook_0.2.3\scripthook\scripting.h(6 ) : error C2059: syntax error : ')'
1>c:\gta iv - pliki\gta iv - mody i pliki\aru c++\gtaivscripthook_0.2.3\scripthook\scripting.h(6 ) : error C2143: syntax error : missing ';' before '{'
1>c:\gta iv - pliki\gta iv - mody i pliki\aru c++\gtaivscripthook_0.2.3\scripthook\scripting.h(6 ) : error C2447: '{' : missing function header (old-style formal list?)
2>c:\gta iv - pliki\gta iv - mody i pliki\aru c++\gtaivscripthook_0.2.3\scripthook\scripting.h(6 ) : error C2653: 'NativeInvoke' : is not a class or namespace name
2>c:\gta iv - pliki\gta iv - mody i pliki\aru c++\gtaivscripthook_0.2.3\scripthook\scripting.h(6 ) : error C3861: 'Invoke': identifier not found
1>c:\gta iv - pliki\gta iv - mody i pliki\aru c++\gtaivscripthook_0.2.3\samplecustom\customthrea d.cpp(31) : error C2065: 'Ped' : undeclared identifier
1>c:\gta iv - pliki\gta iv - mody i pliki\aru c++\gtaivscripthook_0.2.3\samplecustom\customthrea d.cpp(31) : error C2146: syntax error : missing ';' before identifier 'ped'
1>c:\gta iv - pliki\gta iv - mody i pliki\aru c++\gtaivscripthook_0.2.3\samplecustom\customthrea d.cpp(31) : error C2065: 'ped' : undeclared identifier
1>c:\gta iv - pliki\gta iv - mody i pliki\aru c++\gtaivscripthook_0.2.3\samplecustom\customthrea d.cpp(32) : error C2065: 'Vehicle' : undeclared identifier
1>c:\gta iv - pliki\gta iv - mody i pliki\aru c++\gtaivscripthook_0.2.3\samplecustom\customthrea d.cpp(32) : error C2146: syntax error : missing ';' before identifier 'vehicle'
1>c:\gta iv - pliki\gta iv - mody i pliki\aru c++\gtaivscripthook_0.2.3\samplecustom\customthrea d.cpp(32) : error C2065: 'vehicle' : undeclared identifier
1>c:\gta iv - pliki\gta iv - mody i pliki\aru c++\gtaivscripthook_0.2.3\samplecustom\customthrea d.cpp(34) : error C2065: 'ScriptAny' : undeclared identifier
1>c:\gta iv - pliki\gta iv - mody i pliki\aru c++\gtaivscripthook_0.2.3\samplecustom\customthrea d.cpp(34) : error C2146: syntax error : missing ';' before identifier 'unknown'
1>c:\gta iv - pliki\gta iv - mody i pliki\aru c++\gtaivscripthook_0.2.3\samplecustom\customthrea d.cpp(34) : error C2065: 'unknown' : undeclared identifier
1>c:\gta iv - pliki\gta iv - mody i pliki\aru c++\gtaivscripthook_0.2.3\samplecustom\customthrea d.cpp(36) : error C2065: 'Player' : undeclared identifier
1>c:\gta iv - pliki\gta iv - mody i pliki\aru c++\gtaivscripthook_0.2.3\samplecustom\customthrea d.cpp(36) : error C2146: syntax error : missing ';' before identifier 'playerIndex'
1>c:\gta iv - pliki\gta iv - mody i pliki\aru c++\gtaivscripthook_0.2.3\samplecustom\customthrea d.cpp(36) : error C2065: 'playerIndex' : undeclared identifier
1>c:\gta iv - pliki\gta iv - mody i pliki\aru c++\gtaivscripthook_0.2.3\samplecustom\customthrea d.cpp(36) : error C3861: 'ConvertIntToPlayerIndex': identifier not found
1>c:\gta iv - pliki\gta iv - mody i pliki\aru c++\gtaivscripthook_0.2.3\samplecustom\customthrea d.cpp(36) : error C3861: 'GetPlayerId': identifier not found
1>c:\gta iv - pliki\gta iv - mody i pliki\aru c++\gtaivscripthook_0.2.3\samplecustom\customthrea d.cpp(37) : error C2065: 'playerIndex' : undeclared identifier
1>c:\gta iv - pliki\gta iv - mody i pliki\aru c++\gtaivscripthook_0.2.3\samplecustom\customthrea d.cpp(37) : error C2065: 'ped' : undeclared identifier
1>c:\gta iv - pliki\gta iv - mody i pliki\aru c++\gtaivscripthook_0.2.3\samplecustom\customthrea d.cpp(37) : error C3861: 'GetPlayerChar': identifier not found
1>c:\gta iv - pliki\gta iv - mody i pliki\aru c++\gtaivscripthook_0.2.3\samplecustom\customthrea d.cpp(40) : error C2065: 'ped' : undeclared identifier
1>c:\gta iv - pliki\gta iv - mody i pliki\aru c++\gtaivscripthook_0.2.3\samplecustom\customthrea d.cpp(40) : error C3861: 'GetCharCoordinates': identifier not found
2>c:\gta iv - pliki\gta iv - mody i pliki\aru c++\gtaivscripthook_0.2.3\samplecustomfiber\custom fiberthread.cpp(15) : error C3861: 'ConvertIntToPlayerIndex': identifier not found
2>c:\gta iv - pliki\gta iv - mody i pliki\aru c++\gtaivscripthook_0.2.3\samplecustomfiber\custom fiberthread.cpp(15) : error C3861: 'GetPlayerId': identifier not found
1>c:\gta iv - pliki\gta iv - mody i pliki\aru c++\gtaivscripthook_0.2.3\samplecustom\customthrea d.cpp(42) : error C2065: 'unknown' : undeclared identifier
2>c:\gta iv - pliki\gta iv - mody i pliki\aru c++\gtaivscripthook_0.2.3\samplecustomfiber\custom fiberthread.cpp(21) : error C3861: 'GetPlayerChar': identifier not found
1>c:\gta iv - pliki\gta iv - mody i pliki\aru c++\gtaivscripthook_0.2.3\samplecustom\customthrea d.cpp(42) : error C3861: 'GetRandomCarModelInMemory': identifier not found
1>c:\gta iv - pliki\gta iv - mody i pliki\aru c++\gtaivscripthook_0.2.3\samplecustom\customthrea d.cpp(43) : error C2065: 'vehicle' : undeclared identifier
2>c:\gta iv - pliki\gta iv - mody i pliki\aru c++\gtaivscripthook_0.2.3\samplecustomfiber\custom fiberthread.cpp(38) : error C3861: 'RequestAnims': identifier not found
1>c:\gta iv - pliki\gta iv - mody i pliki\aru c++\gtaivscripthook_0.2.3\samplecustom\customthrea d.cpp(43) : error C3861: 'CreateCar': identifier not found
1>c:\gta iv - pliki\gta iv - mody i pliki\aru c++\gtaivscripthook_0.2.3\samplecustom\customthrea d.cpp(49) : error C2065: 'Player' : undeclared identifier
2>c:\gta iv - pliki\gta iv - mody i pliki\aru c++\gtaivscripthook_0.2.3\samplecustomfiber\custom fiberthread.cpp(42) : error C3861: 'HaveAnimsLoaded': identifier not found
1>c:\gta iv - pliki\gta iv - mody i pliki\aru c++\gtaivscripthook_0.2.3\samplecustom\customthrea d.cpp(49) : error C2146: syntax error : missing ';' before identifier 'playerIndex'
1>c:\gta iv - pliki\gta iv - mody i pliki\aru c++\gtaivscripthook_0.2.3\samplecustom\customthrea d.cpp(49) : error C2065: 'playerIndex' : undeclared identifier
1>c:\gta iv - pliki\gta iv - mody i pliki\aru c++\gtaivscripthook_0.2.3\samplecustom\customthrea d.cpp(49) : error C3861: 'ConvertIntToPlayerIndex': identifier not found
2>Generating Code...
1>c:\gta iv - pliki\gta iv - mody i pliki\aru c++\gtaivscripthook_0.2.3\samplecustom\customthrea d.cpp(49) : error C3861: 'GetPlayerId': identifier not found
1>c:\gta iv - pliki\gta iv - mody i pliki\aru c++\gtaivscripthook_0.2.3\samplecustom\customthrea d.cpp(50) : error C2065: 'playerIndex' : undeclared identifier
1>c:\gta iv - pliki\gta iv - mody i pliki\aru c++\gtaivscripthook_0.2.3\samplecustom\customthrea d.cpp(50) : error C3861: 'AddScore': identifier not found
1>c:\gta iv - pliki\gta iv - mody i pliki\aru c++\gtaivscripthook_0.2.3\samplecustom\customthrea d.cpp(58) : error C3861: 'RequestModel': identifier not found
1>c:\gta iv - pliki\gta iv - mody i pliki\aru c++\gtaivscripthook_0.2.3\samplecustom\customthrea d.cpp(69) : error C3861: 'RequestModel': identifier not found
1>c:\gta iv - pliki\gta iv - mody i pliki\aru c++\gtaivscripthook_0.2.3\samplecustom\customthrea d.cpp(80) : error C3861: 'RequestModel': identifier not found
1>c:\gta iv - pliki\gta iv - mody i pliki\aru c++\gtaivscripthook_0.2.3\samplecustom\customthrea d.cpp(90) : error C3861: 'HasModelLoaded': identifier not found
1>c:\gta iv - pliki\gta iv - mody i pliki\aru c++\gtaivscripthook_0.2.3\samplecustom\customthrea d.cpp(94) : error C2065: 'Ped' : undeclared identifier
1>c:\gta iv - pliki\gta iv - mody i pliki\aru c++\gtaivscripthook_0.2.3\samplecustom\customthrea d.cpp(94) : error C2146: syntax error : missing ';' before identifier 'ped'
1>c:\gta iv - pliki\gta iv - mody i pliki\aru c++\gtaivscripthook_0.2.3\samplecustom\customthrea d.cpp(94) : error C2065: 'ped' : undeclared identifier
1>c:\gta iv - pliki\gta iv - mody i pliki\aru c++\gtaivscripthook_0.2.3\samplecustom\customthrea d.cpp(95) : error C2065: 'Vehicle' : undeclared identifier
1>c:\gta iv - pliki\gta iv - mody i pliki\aru c++\gtaivscripthook_0.2.3\samplecustom\customthrea d.cpp(95) : error C2146: syntax error : missing ';' before identifier 'vehicle'
1>c:\gta iv - pliki\gta iv - mody i pliki\aru c++\gtaivscripthook_0.2.3\samplecustom\customthrea d.cpp(95) : error C2065: 'vehicle' : undeclared identifier
1>c:\gta iv - pliki\gta iv - mody i pliki\aru c++\gtaivscripthook_0.2.3\samplecustom\customthrea d.cpp(98) : error C2065: 'Player' : undeclared identifier
1>c:\gta iv - pliki\gta iv - mody i pliki\aru c++\gtaivscripthook_0.2.3\samplecustom\customthrea d.cpp(98) : error C2146: syntax error : missing ';' before identifier 'playerIndex'
1>c:\gta iv - pliki\gta iv - mody i pliki\aru c++\gtaivscripthook_0.2.3\samplecustom\customthrea d.cpp(98) : error C2065: 'playerIndex' : undeclared identifier
1>c:\gta iv - pliki\gta iv - mody i pliki\aru c++\gtaivscripthook_0.2.3\samplecustom\customthrea d.cpp(98) : error C3861: 'ConvertIntToPlayerIndex': identifier not found
1>c:\gta iv - pliki\gta iv - mody i pliki\aru c++\gtaivscripthook_0.2.3\samplecustom\customthrea d.cpp(98) : error C3861: 'GetPlayerId': identifier not found
1>c:\gta iv - pliki\gta iv - mody i pliki\aru c++\gtaivscripthook_0.2.3\samplecustom\customthrea d.cpp(99) : error C2065: 'playerIndex' : undeclared identifier
2>Compiling...
1>c:\gta iv - pliki\gta iv - mody i pliki\aru c++\gtaivscripthook_0.2.3\samplecustom\customthrea d.cpp(99) : error C2065: 'ped' : undeclared identifier
1>c:\gta iv - pliki\gta iv - mody i pliki\aru c++\gtaivscripthook_0.2.3\samplecustom\customthrea d.cpp(99) : error C3861: 'GetPlayerChar': identifier not found
1>c:\gta iv - pliki\gta iv - mody i pliki\aru c++\gtaivscripthook_0.2.3\samplecustom\customthrea d.cpp(101) : error C2065: 'ped' : undeclared identifier
1>c:\gta iv - pliki\gta iv - mody i pliki\aru c++\gtaivscripthook_0.2.3\samplecustom\customthrea d.cpp(101) : error C3861: 'GetCharCoordinates': identifier not found
1>c:\gta iv - pliki\gta iv - mody i pliki\aru c++\gtaivscripthook_0.2.3\samplecustom\customthrea d.cpp(103) : error C2065: 'vehicle' : undeclared identifier
1>c:\gta iv - pliki\gta iv - mody i pliki\aru c++\gtaivscripthook_0.2.3\samplecustom\customthrea d.cpp(103) : error C3861: 'CreateCar': identifier not found
1>c:\gta iv - pliki\gta iv - mody i pliki\aru c++\gtaivscripthook_0.2.3\samplecustom\customthrea d.cpp(105) : error C3861: 'MarkModelAsNoLongerNeeded': identifier not found
1>c:\gta iv - pliki\gta iv - mody i pliki\aru c++\gtaivscripthook_0.2.3\samplecustom\customthrea d.cpp(114) : error C3861: 'HasModelLoaded': identifier not found
1>c:\gta iv - pliki\gta iv - mody i pliki\aru c++\gtaivscripthook_0.2.3\samplecustom\customthrea d.cpp(118) : error C2065: 'Player' : undeclared identifier
1>c:\gta iv - pliki\gta iv - mody i pliki\aru c++\gtaivscripthook_0.2.3\samplecustom\customthrea d.cpp(118) : error C2146: syntax error : missing ';' before identifier 'playerIndex'
1>c:\gta iv - pliki\gta iv - mody i pliki\aru c++\gtaivscripthook_0.2.3\samplecustom\customthrea d.cpp(118) : error C2065: 'playerIndex' : undeclared identifier
1>c:\gta iv - pliki\gta iv - mody i pliki\aru c++\gtaivscripthook_0.2.3\samplecustom\customthrea d.cpp(118) : error C3861: 'ConvertIntToPlayerIndex': identifier not found
1>c:\gta iv - pliki\gta iv - mody i pliki\aru c++\gtaivscripthook_0.2.3\samplecustom\customthrea d.cpp(118) : error C3861: 'GetPlayerId': identifier not found
1>c:\gta iv - pliki\gta iv - mody i pliki\aru c++\gtaivscripthook_0.2.3\samplecustom\customthrea d.cpp(121) : error C2065: 'Ped' : undeclared identifier
1>c:\gta iv - pliki\gta iv - mody i pliki\aru c++\gtaivscripthook_0.2.3\samplecustom\customthrea d.cpp(121) : error C2146: syntax error : missing ';' before identifier 'ped'
1>c:\gta iv - pliki\gta iv - mody i pliki\aru c++\gtaivscripthook_0.2.3\samplecustom\customthrea d.cpp(121) : error C2065: 'ped' : undeclared identifier
1>c:\gta iv - pliki\gta iv - mody i pliki\aru c++\gtaivscripthook_0.2.3\samplecustom\customthrea d.cpp(123) : error C2065: 'playerIndex' : undeclared identifier
1>c:\gta iv - pliki\gta iv - mody i pliki\aru c++\gtaivscripthook_0.2.3\samplecustom\customthrea d.cpp(123) : error C2065: 'ped' : undeclared identifier
1>c:\gta iv - pliki\gta iv - mody i pliki\aru c++\gtaivscripthook_0.2.3\samplecustom\customthrea d.cpp(123) : error C3861: 'GetPlayerChar': identifier not found
1>c:\gta iv - pliki\gta iv - mody i pliki\aru c++\gtaivscripthook_0.2.3\samplecustom\customthrea d.cpp(124) : error C2065: 'ped' : undeclared identifier
1>c:\gta iv - pliki\gta iv - mody i pliki\aru c++\gtaivscripthook_0.2.3\samplecustom\customthrea d.cpp(124) : error C3861: 'GetKeyForCharInRoom': identifier not found
1>c:\gta iv - pliki\gta iv - mody i pliki\aru c++\gtaivscripthook_0.2.3\samplecustom\customthrea d.cpp(126) : error C2065: 'playerIndex' : undeclared identifier
1>c:\gta iv - pliki\gta iv - mody i pliki\aru c++\gtaivscripthook_0.2.3\samplecustom\customthrea d.cpp(126) : error C3861: 'ChangePlayerModel': identifier not found
1>c:\gta iv - pliki\gta iv - mody i pliki\aru c++\gtaivscripthook_0.2.3\samplecustom\customthrea d.cpp(128) : error C2065: 'playerIndex' : undeclared identifier
1>c:\gta iv - pliki\gta iv - mody i pliki\aru c++\gtaivscripthook_0.2.3\samplecustom\customthrea d.cpp(128) : error C2065: 'ped' : undeclared identifier
1>c:\gta iv - pliki\gta iv - mody i pliki\aru c++\gtaivscripthook_0.2.3\samplecustom\customthrea d.cpp(128) : error C3861: 'GetPlayerChar': identifier not found
2>Main.cpp
1>c:\gta iv - pliki\gta iv - mody i pliki\aru c++\gtaivscripthook_0.2.3\samplecustom\customthrea d.cpp(129) : error C2065: 'ped' : undeclared identifier
1>c:\gta iv - pliki\gta iv - mody i pliki\aru c++\gtaivscripthook_0.2.3\samplecustom\customthrea d.cpp(129) : error C3861: 'SetRoomForCharByKey': identifier not found
1>c:\gta iv - pliki\gta iv - mody i pliki\aru c++\gtaivscripthook_0.2.3\samplecustom\customthrea d.cpp(131) : error C3861: 'MarkModelAsNoLongerNeeded': identifier not found
1>Build log was saved at "file://c:\GTA IV - Pliki\GTA IV - Mody i Pliki\aru C++\GTAIVScriptHook_0.2.3\SampleCustom\Debug\Build Log.htm"
1>SampleCustom - 81 error(s), 0 warning(s)
2>Generating Code...
2>Build log was saved at "file://c:\GTA IV - Pliki\GTA IV - Mody i Pliki\aru C++\GTAIVScriptHook_0.2.3\SampleCustomFiber\Debug\ BuildLog.htm"
2>SampleCustomFiber - 7 error(s), 0 warning(s)
========== Build: 0 succeeded, 2 failed, 1 up-to-date, 0 skipped ==========
rappo
05-25-2009, 03:33 PM
Right click the project you are working on, go to "Project Dependencies" and make sure that "ScriptHook" is checked. Then try to compile again. I'm not sure if that is the exact problem but it looks like it.
Leito
05-26-2009, 08:29 AM
Don't run. This same error.
rappo
05-26-2009, 09:40 PM
Aight can you post your code? You might be missing a "using namespace Scripting" somewhere.
Leito
05-27-2009, 07:04 AM
Sure, but this code is this same what you have in post up.
CustomFiberThread.cpp
#include "CustomFiberThread.h"
#include "Scripting.h"
#include "../ScriptHook/Log.h"
#include <windows.h>
using namespace Scripting;
CustomFiberThread::CustomFiberThread(){
SetName("Animation");
setDefaultValues();
}
Player CustomFiberThread::GetPlayer() {
Player playerIndex = ConvertIntToPlayerIndex(GetPlayerId());
return playerIndex;
}
Scripting::Ped CustomFiberThread::GetPlayerPed() {
Ped ped;
GetPlayerChar(GetPlayer(), &ped);
return ped;
}
void CustomFiberThread::setDefaultValues() {
playSpliff = false;
}
void CustomFiberThread::Start() {
setDefaultValues();
NativeThread::Start();
}
void CustomFiberThread::RunScript() {
while(IsThreadAlive()) {
if((GetAsyncKeyState(VK_F12) && 1) != 0) {
LogInfo("Requesting spliff animation");
RequestAnims("amb@smoking_spliff");
playSpliff = true;
}
if(playSpliff && HaveAnimsLoaded("amb@smoking_spliff")) {
LogInfo("Playing spliff animation");
TaskPlayAnim(GetPlayerPed(), "create_spliff", "amb@smoking_spliff", 4.0f, 0, 0, 0, 0, -1);
playSpliff = false;
}
Wait(100);
}
}
Scripting.h
#pragma once
#include "../ScriptHook/Scripting.h"
namespace Scripting {
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("TASK_PLAY_ANIM", ped, animSequence, animName, speed, loop, x, y, z, ms); }
}
CustomFiberThread.h
#pragma once
#include "../ScriptHook/NativeFiberThread.h"
#include "../ScriptHook/ScriptingEnums.h"
#include "../ScriptHook/ScriptingTypes.h"
class CustomFiberThread : public NativeFiberThread {
private:
Scripting::Player GetPlayer();
Scripting::Ped GetPlayerPed();
b8 playSpliff;
protected:
void RunScript();
void setDefaultValues();
void Start();
public:
CustomFiberThread();
};
rappo
05-27-2009, 09:56 AM
okay you must be missing the scripthook then. you have to have all these folders in the same place so that they can use the same files. also keep your file names consistent. your errors say error in scripting.h but you have #include "Scripting.h" - make sure youve got the correct capitalization. Don't rename any of the files or folders that aru gave
Leito
05-29-2009, 10:42 AM
But i'm don't renamed folders and files. Ah, i don't know what's going on... ;/ But in original, straight from aru, building normal -.-
rappo
05-29-2009, 09:21 PM
sorry i don't know what to tell you - there is nothing wrong with the code, it's the way that you set up your project. you need to make sure all the project dependencies are set and that all the folders are in the correct place. unforatunely there isnt much i can do to help you with that unless i am using your computer :P
Leito
05-30-2009, 07:13 PM
Ok, thanks for help. Maybe it Windows7. My dad have XP. I'll check and write here.