Having problems with C++ [message #335728] |
Tue, 17 June 2008 19:10 |
HeavyX101- Left
Messages: 633 Registered: April 2008 Location: WindowsJail=ZipFolder
Karma: 0
|
Colonel |
|
|
I'm having problems with this code.
I want to make a command that arests a player and teleports it into a zone.
Zone id = 100054
Here is the code:
class jailChatCommand : public ChatCommandClass {
void Triggered(int ID,const TokenClass &Text,int ChatType) {
if (!Text[1].empty() ) {
int player = atoi(Text[1].c_str());
GameObject *obj = Get_GameObj(player);
int x = ?????????("100054");
GameObject *gotoObject = Commands->Find_Object(x);
Vector3 gotoLocation = Commands->Get_Position(gotoObject);
Commands->Set_Position(obj,gotoLocation);
}
else {
Console_Input(StrFormat("ppage %d ERROR!",ID).c_str());
}
}
};
ChatCommandRegistrant<jailChatCommand> jailChatCommandReg("!jail",CHATTYPE_ALL,1,GAMEMODE_AOW);
I dont know what to put in the place where are the ???????.
Do any of you guys know what i could put there?
I got it from a script and it was Get_Int_Parameter but it is getting a error:
Quote: | 1>.\gmmain.cpp(3116) : error C3861: 'Get_Int_Parameter': identifier not found
|
This account is no longer being active.
|
|
|
|
Re: Having problems with C++ [message #335731 is a reply to message #335729] |
Tue, 17 June 2008 19:31 |
HeavyX101- Left
Messages: 633 Registered: April 2008 Location: WindowsJail=ZipFolder
Karma: 0
|
Colonel |
|
|
Works perfect, thanks.
Do you know a !sell all code?
I cant seem to figure out how to make it. I made one but when i die, i cant sell my objects any more.
This account is no longer being active.
|
|
|
|
Re: Having problems with C++ [message #335814 is a reply to message #335771] |
Wed, 18 June 2008 09:31 |
HeavyX101- Left
Messages: 633 Registered: April 2008 Location: WindowsJail=ZipFolder
Karma: 0
|
Colonel |
|
|
madrackz wrote on Wed, 18 June 2008 06:28 |
HeavyX101 wrote on Tue, 17 June 2008 21:31 | Works perfect, thanks.
Do you know a !sell all code?
I cant seem to figure out how to make it. I made one but when i die, i cant sell my objects any more.
|
Do it with INI´s, then "save" the ID of the Object.
|
Well, i cant do that cuz i dont know how to save the files. Well, i might learn it. Thanks for helping guys
This account is no longer being active.
|
|
|
Re: Having problems with C++ [message #335831 is a reply to message #335814] |
Wed, 18 June 2008 12:17 |
HeavyX101- Left
Messages: 633 Registered: April 2008 Location: WindowsJail=ZipFolder
Karma: 0
|
Colonel |
|
|
Sorry for double post.
But i need your help guys.
class jailChatCommand : public ChatCommandClass {
void Triggered(int ID,const TokenClass &Text,int ChatType) {
if (!Text[1].empty() ) {
const char *pris = Get_Player_Name(Get_Part_Name(Text[1].c_str()));
int player = atoi(pris);
GameObject *obj = Get_GameObj(player);
int x = 100054;
GameObject *gotoObject = Commands->Find_Object(x);
Vector3 gotoLocation = Commands->Get_Position(gotoObject);
Commands->Set_Position(obj,gotoLocation);
Change_Character(obj,"GDI_Prisoner_v0a");
Commands->Set_Shield_Type(obj,"Blamo");
Console_Input(StrFormat("cmsg 166,149,56 [BSS: %d Has Been Arrested ]", Get_Player_ID(Get_Part_Name(Text[1].c_str()))).c_str());
}
else {
Console_Input(StrFormat("ppage %d ERROR!",ID).c_str());
}
}
};
ChatCommandRegistrant<jailChatCommand> jailChatCommandReg("!jail;!j",CHATTYPE_ALL,1,GAMEMODE_AOW);
It compiled fine. But ingame, when i write !jail HeavyX101 , it says the message "[BSS: -1 Has Been Arrested ]" but it is not putting me into the jail. Why is that?
This account is no longer being active.
|
|
|
|
Re: Having problems with C++ [message #335840 is a reply to message #335837] |
Wed, 18 June 2008 13:25 |
HeavyX101- Left
Messages: 633 Registered: April 2008 Location: WindowsJail=ZipFolder
Karma: 0
|
Colonel |
|
|
Ok, this is what i did now:
class jailChatCommand : public ChatCommandClass {
void Triggered(int ID,const TokenClass &Text,int ChatType) {
if (!Text[1].empty() ) {
const char *pris = Get_Player_Name(Get_Part_Name(Text[1].c_str()));
GameObject *obj = Get_GameObj(pris);
int x = 100054;
GameObject *gotoObject = Commands->Find_Object(x);
Vector3 gotoLocation = Commands->Get_Position(gotoObject);
Commands->Set_Position(obj,gotoLocation);
Change_Character(obj,"GDI_Prisoner_v0a");
Commands->Set_Shield_Type(obj,"Blamo");
Console_Input(StrFormat("cmsg 166,149,56 [BSS: %d Has Been Arrested ]", Get_Player_ID(Get_Part_Name(Text[1].c_str()))).c_str());
}
else {
Console_Input(StrFormat("ppage %d ERROR!",ID).c_str());
}
}
};
ChatCommandRegistrant<jailChatCommand> jailChatCommandReg("!jail;!j",CHATTYPE_ALL,1,GAMEMODE_AOW);
I get this error:
Quote: | Error 1 error C2664: 'Get_GameObj' : cannot convert parameter 1 from 'const char *' to 'int' c:\Westwood\RenegadeFDS\Server\gmmain.cpp 3222
|
This account is no longer being active.
|
|
|
Re: Having problems with C++ [message #335849 is a reply to message #335728] |
Wed, 18 June 2008 14:12 |
|
jnz
Messages: 3396 Registered: July 2006 Location: 30th century
Karma: 0
|
General (3 Stars) |
|
|
Get_GameObj needs a player ID.
class jailChatCommand : public ChatCommandClass {
void Triggered(int ID,const TokenClass &Text,int ChatType) {
if (!Text[1].empty() ) {
const char *pris = Get_Player_Name(Get_Part_Name(Text[1].c_str()));
GameObject *obj = Get_GameObj_By_Player_Name(pris);
int x = 100054;
GameObject *gotoObject = Commands->Find_Object(x);
Vector3 gotoLocation = Commands->Get_Position(gotoObject);
Commands->Set_Position(obj,gotoLocation);
Change_Character(obj,"GDI_Prisoner_v0a");
Commands->Set_Shield_Type(obj,"Blamo");
Console_Input(StrFormat("cmsg 166,149,56 [BSS: %d Has Been Arrested ]", Get_Player_ID(Get_Part_Name(Text[1].c_str()))).c_str());
}
else {
Console_Input(StrFormat("ppage %d ERROR!",ID).c_str());
}
}
};
ChatCommandRegistrant<jailChatCommand> jailChatCommandReg("!jail;!j",CHATTYPE_ALL,1,GAMEMODE_AOW);
|
|
|
Re: Having problems with C++ [message #335853 is a reply to message #335849] |
Wed, 18 June 2008 14:52 |
HeavyX101- Left
Messages: 633 Registered: April 2008 Location: WindowsJail=ZipFolder
Karma: 0
|
Colonel |
|
|
Compiled but it still doesnt teleport me to the jail.
I think it is this line:
Quote: | const char *pris = Get_Player_Name(Get_Part_Name(Text[1].c_str()));
|
This account is no longer being active.
|
|
|
|
|
|
|