yes you could just type cmd1 155 in the console and get the same result without the alias the alias is just to make it user friendly.
Announcement
Collapse
No announcement yet.
Possible to have a coop server auto restart when 'end' has been won?
Collapse
X
-
ok, well that isn't working. Says 'Unknown command cmd1'
However if I use temp1 then I don't get that error, but it still doesn't register:
I tried 'temp1 10' and 'set temp1 10'Code:void() vote_command = { local float command; command = cvar("temp1"); bprint(ftos(command)); bprint("\n"); //cvar_set("temp1", "0"); if (command) bprint("TEST\n"); };Last edited by slackhead; 09-11-2014, 05:12 PM.
-r0t.uk- cOOp - Mapvote - r0t.uk:26001
-r0t.uk- DM - Mapvote - r0t.uk:26000
Comment
-
I am not sure what the issue here is but maybe something is wrong in your code. So here is a simplified example. In world.qc near the top place this:
And place this at the bottom of StartFrame in world.qc:Code:void () vote_command = { local float command; command = cvar("temp1"); cvar_set("temp1", "0"); if (command) if (command == 1) sprint(self,"TEST\n"); else sprint(self,"unknown command\n"); };
No need for "set temp1 1" because this is a builtin.Code:vote_command ();
That is it. Basically when you enter the server you'll be able to type temp1 "1" and it will send you a sprint to self letting you know the command works. Now type anything else besides one like temp1 "3" and it will kick back an unkown command sprint. Now if you want you can make an alias for it by typing this in the console:
Now you can just use test. So this is as simple as I can make it. This should work no question. I am not sure about why you are getting the unknown command error if you are doing it like this. Maybe post whatever code you were using? I suppose I was confusing with the use of cmd1 but I had forgotten about the temp1 builtin for mods. So my apologies if it has been confusing you. My instructions are not always well thought out.Code:alias test "temp1 1"
Obviously most of the code I send assumed using arrays and additional functions to set up alias to the client machines using a call to stuffcmd. But for testing this will show you that they at least work.
Comment
-
Wha? Remember sprint will not automatically print to the console until you press ~ and go back to console again. But you don't need to use sprint. It was just an example. I have no idea why you aren't getting an output but show your code and I'll check. Something simple must be wrong. Are you just not getting an output or actually getting an error?
Comment
-
andCode:void () vote_command = { local float command; command = cvar("temp1"); cvar_set("temp1", "0"); if (command) if (command == 1) sprint(self,"TEST\n"); else sprint(self,"unknown command\n"); };
I copy/pasted yours.Code:void() StartFrame = { teamplay = cvar("teamplay"); skill = cvar("skill"); framecount = framecount + 1; vote_command(); };
-r0t.uk- cOOp - Mapvote - r0t.uk:26001
-r0t.uk- DM - Mapvote - r0t.uk:26000
Comment
-
you could do something like
stuffcmd(self,"alias tacos impulse 201\n");
somewhere parse impulse 201 then set temp1 = self.impulse - 200; vote_command();
Comment
-
Ah ok. I made the assumption you were testing this locally. Here ya go use this instead for a quick test to get an echo.
Everything else is the same. The other code only works if you are the local server (IN DP anyway). Otherwise it is trying to send the command to a non-client. :/ LOL! So this will work. You could also use that custom localcmd function from earlier here if you want to clean this up a bit. But this will echo test or unknown command depending on the situation. This works because now we are sending a localcmd to the server that is actually using the command. Make sense? Before it was assuming self and it couldn't find a self because it runs that code in world.qc. If it had been running in Postthink or similar self would have applied. Hope that makes sense. Sorry bout that.Code:void () vote_command = { local float command; command = cvar("temp1"); cvar_set("temp1", "0"); if (command) if (command == 1) { localcmd("echo "); localcmd("TEST"); localcmd("\n"); } else { localcmd("echo "); localcmd("unknown command"); localcmd("\n"); } };
I shouldn't have assumed.
Last edited by PrimalLove; 09-11-2014, 07:25 PM.
Comment
-
Great, that prints in the server console
Still not sure why bprint() doesn't work though... I'd probably want to use that at some point to let players know that a vote has started
-r0t.uk- cOOp - Mapvote - r0t.uk:26001
-r0t.uk- DM - Mapvote - r0t.uk:26000
Comment
-
-
Arg. It still isn't working. When I checked it I up-arrowed to the last command, which was an rcon command... (I tested rcon earlier to see what would happen)...
I think r00k is right and I'd have to use an impulse to set it or some such.
-r0t.uk- cOOp - Mapvote - r0t.uk:26001
-r0t.uk- DM - Mapvote - r0t.uk:26000
Comment
-
Looking at and testing it, command never resolves to anything but 0. I think that the client isn't sending the var temp1 to the server. Maybe that's why so many of the tutorials I've looked at use impulse...
-r0t.uk- cOOp - Mapvote - r0t.uk:26001
-r0t.uk- DM - Mapvote - r0t.uk:26000
Comment
Comment