An error and a question - Printable Version +- Cuberite Forum (https://forum.cuberite.org) +-- Forum: Plugins (https://forum.cuberite.org/forum-1.html) +--- Forum: Plugin Discussion (https://forum.cuberite.org/forum-8.html) +--- Thread: An error and a question (/thread-869.html) |
An error and a question - tonibm19 - 05-01-2013 First the error: with this code, when I execute a command, it says Unknow command and Player not found, but the code is executed, for my case it gives me the error I said, but mobs spawned. Code: function HandleApocalypseCommand( Split, Player ) Now the question: Is there any way of set a player on fire? I searched in API.txt and I con't find anything to to that. RE: Any way to set a player on fire? - NiLSPACE - 05-01-2013 the only way i can think of is by settings the block where the player is on fire. RE: Any way to set a player on fire? - tonibm19 - 05-01-2013 (05-01-2013, 04:42 AM)STR_Warrior Wrote: the only way i can think of is by settings the block where the player is on fire.Ok, I'll search in the API RE: An error and a question - NiLSPACE - 05-01-2013 (05-01-2013, 04:29 AM)tonibm19 Wrote: First the error:for the unknown command, its easy. put return true before the last end. i think you should change " if (HasKilled) then" to "if HasKilled == true then" RE: An error and a question - xoft - 05-01-2013 (05-01-2013, 04:54 AM)STR_Warrior Wrote: i think you should change " if (HasKilled) then" to "if HasKilled == true then" Definitely NOT. Do NOT compare boolean values, that's bad practice in C++ and makes the code less readable. I think the problem is that you're using two variable names: You have HasSpawned and set HasSpawned to true, but then test HasKilled, which, in this piece of code, is undeclared. RE: An error and a question - NiLSPACE - 05-01-2013 (05-01-2013, 06:02 AM)xoft Wrote: Definitely NOT. Do NOT compare boolean values, that's bad practice in C++ and makes the code less readable. oooowwwww... oops RE: An error and a question - xoft - 05-01-2013 Setting the player on fire is not yet possible through the API (and even MCServer does a really poor job, especially of un-setting the fire). We haven't yet reached a consensus on where exactly to put the fire handling, whether into cEntity or cPawn. (05-01-2013, 06:02 AM)xoft Wrote: Definitely NOT. Do NOT compare boolean values, that's bad practice in C++ and makes the code less readable. To elaborate on that a bit, although I'm gonna be talking C/C++ here, it might be different in Lua: Imagine you have two bool values and want to compare them. An unsuspecting victim might try a simple code like if (BoolVal1 == BoolVal2)However, this won't work. The compiler is free to use zero for false and nonzero for true, which means two values that are logically true needn't be actually equal. "5" is true, "7" is true, but 5 != 7. Doing a comparison like if (BoolVal == true)you're comparing BoolVal's value (which could be a number, really) with "1" or "-1" or even "255", depending on the compiler. From another point of view, using code like this is somewhat misleading: if (ShouldDoIt == false) So the best practice is to use bool values directly: if (ShouldDoIt) { DoIt(); } if (!ShouldExit) { DoIt(); } RE: An error and a question - tonibm19 - 05-01-2013 (05-01-2013, 06:02 AM)xoft Wrote: I think the problem is that you're using two variable names: You have HasSpawned and set HasSpawned to true, but then test HasKilled, which, in this piece of code, is undeclared.No, it isn't, i did this error only with this command. With other commands like /creeper it works. As STR_Warrior said, I thing that the problem is that I didn't put return true in the final. I'll fix it. |