Author Topic: how do I make it so when I type in something in the chat, something happens  (Read 3473 times)

If you're just making a fling function you don't need to use what I said at all, that was only when you wanted to do something when an admin put a command in the chat.

Also you forgot a % before %client.isAdmin on line 5.

The getWord(string, int) was an example, I was telling you what to put in. It isn't needed in the function that you posted. That was only used to get parts of a message.

If you're just making a fling function you don't need to use what I said at all, that was only when you wanted to do something when an admin put a command in the chat.

Also you forgot a % before %client.isAdmin on line 5.

The getWord(string, int) was an example, I was telling you what to put in. It isn't needed in the function that you posted. That was only used to get parts of a message.
s
alright thanks!


If you're just making a fling function you don't need to use what I said at all, that was only when you wanted to do something when an admin put a command in the chat.

Also you forgot a % before %client.isAdmin on line 5.

The getWord(string, int) was an example, I was telling you what to put in. It isn't needed in the function that you posted. That was only used to get parts of a message.
I wanted to make it so if an admin said /fling (playername) it sets the targets Velocity to 255,
I tried to do the script in single player and multiplayer and it didn't work.
« Last Edit: August 17, 2015, 09:08:05 AM by Bow »

I wanted to make it so if an admin said /fling (playername) it sets the targets Velocity to 255,
I tried to do the script in single player and multiplayer and it didn't work.
Remember. You'll always have to give us the code or we won't know what you did wrong. It's like telling a doctor "I'm sick. Cure me." without telling him your symptoms or why you think you're sick.

Remember. You'll always have to give us the code or we won't know what you did wrong. It's like telling a doctor "I'm sick. Cure me." without telling him your symptoms or why you think you're sick.
Whoops! sorry
Code: [Select]
function serverCmdFling(%client, %word1, %word2, %word3, %word4, %etc)
{
        if(isObject(%client.player))
        {
if(%client.isadmin)
{
               
getWord(string, int)
%target = findClientByName(getWord(%msg, 1));
if(isObject(%target))
    %client.player.addVelocity("0 0 255"(%client, %target));

        }
        messageAll('', %client.getPlayerName() SPC "Has been flung by one of the admins!");
}

You're still missing a closing bracket ( } ).

You don't need to use getWord in this function. You can simple do %target = findClientByName(%word1);. You don't even need the rest of the %words. Also remove getWord(string, int) because that does nothing except give you an error as it was an example.

Also when you announce who has been flung and when you actually add their velocity you're doing it to the player who typed the command, not your target.

Also when you announce who has been flung and when you actually add their velocity you're doing it to the player who typed the command, not your target.
Also similarly, you're checking if the player who typed the command exists, rather than the player you're trying to fling.

Your findClientByName call is going to have to be the first thing to do if you're checking if the player object exists first


EDIT: oh wait, you are checking if %target exists, I didn't see that. That should be %target.player, though, and the isObject check on %client.player isn't needed unless being unusable if you're not spawned is the logic you want. And the(%client, %target) in the addVelocity call doesn't do anything but cause errors. The arguments are just "0 0 255"

And you can get rid of all the arguments except %client and %word1 (which I'd remember to something more descriptive, like targetname or victim) since you're not doing anything with them
« Last Edit: August 17, 2015, 10:36:24 AM by Headcrab Zombie »

Still not working, heres the file
http://www.mediafire.com/download/c162s2arhz5i6wj/Server_Fling.zip
please bare me if I missed something or I did something wrong :)

Quote
Code: [Select]
%target.player
You can't set dynamic fields (.player) on things that aren't a object. %target = .. will suffice.
Quote
Code: [Select]
%client.player.addVelocity("0 0 255")
Statements like this one need a ; at the end of it, if statements, for one, don't.

Also you shouldn't announce the flinging if the client isn't admin and/or the player doesn't exist.

Also you shouldn't announce the flinging if the cl ient isn't admin and/or the player doesn't exist.
so should I add if(%client.admin) ?

so should I add if(%client.admin) ?
Just stick it in with the same if block as addvelocity
Also your addvelocity call still needs to be target, not client

You seem to be much too stuck so I wrote the entire command from the start. What I want you to do, is to tell us what you think each part does, and if needed, we'll correct you.

Code: [Select]
function serverCmdFling(%client, %target)
{
if(%client.isAdmin)
{
%target = findClientByName(%target);
%player = %target.player;
if(isObject(%player))
{
%player.setVelocity("0 0 250");
talk(%client.getPlayerName() SPC "has flung" SPC %target.getPlayerName() @ ".");
}
else
{
messageClient(%client, 0, "Player associated to client not found!");
}
}
else
{
messageClient(%client, 0, "You must be an admin to use this command!");
}
}
« Last Edit: August 17, 2015, 02:50:08 PM by Dannu »

You seem to be much too stuck so I wrote the entire command from the start. What I want you to do, is to tell us what you think each part does, and if needed, we'll correct you.

Code: [Select]
function serverCmdFling(%client, %target)
{
if(%client.isAdmin)
{
%player = findClientByName(%target);
if(isObject(%player))
{
%player.setVelocity("0 0 250");
%targetClient = %player.client;
talk(%client.name SPC "has flung" SPC %targetClient.name @ ".");
}
else
{
messageClient(%client, 0, "Player associated to client not found!");
}
}
else
{
messageClient(%client, 0, "You must be an admin to use this command!");
}
}
You messed up.
Should be:
Code: [Select]
%target = findClientByName(%target);
%player = %target.player;
And then don't define %targetClient and use %target instead.