onPlayerChat: Example

Started by Mötley, Mar 05, 2016, 05:17 PM

Previous topic - Next topic

Mötley

Just a Simple example of the chat, or enough to help you get started with the function onPlayerChat

This should help if you are about to build a mute system, and or is nice to have for players that like to spam before joining, or just lazy and do not want to build that function


function onPlayerChat( Player, Text ) {

  local White = "[#ffffff]", Chat = "[#ff0000] ";

  if ( Player.IsSpawned )
  {
     Message( "[" + Player.ID  + "] " + Chat + Player + ": " + White + Text );
  }
  else {
     MessagePlayer("" + White + "You cannot use chat. You must spawn", Player );
  }

  return 0;

}


.

#1
You do know that there's a Wiki for that? Are we seriously going to create a topic for every module function?
.

Mötley

Are you seriously going to spam this with hate?

[Rant]
Maybe if i had guidance and could get a little bit of help due to everything requires modules, instead of being built in (what i am used to).

I could do way more.

Read the code, its not like the wiki version. There is other examples there

.

#3
Quote from: Mr_Motley on Mar 05, 2016, 05:28 PMAre you seriously going to spam this with hate?

Do you know why I SPAM WITH SH!T? Because no one comes here to look for how a function looks! People will make a new topic if they don't find it in the Wiki. Which results in more forum spam with more useless questions. So do you think you're helping anyone? No, not really.
.

Mötley

Looking in the Snippet's should be your first choice, or do a web search as another player might of had the same issue as yourself and had there problem solved. Your attitude is Flaming.

.

Quote from: Mr_Motley on Mar 05, 2016, 05:43 PMLooking in the Snippet's should be your first choice, or do a web search as another player might of had the same issue as yourself and had there problem solved. Your attitude is Flaming.

Oh seriously? Have you ever looked here? Does anyone ever look here? Do you know that I (literally) get at least 2-3 questions every day about things that exist here? And I have to go and look 2-3 pages back (because it's full of sh!t in here) to find that particular snippet? Can you stop being so ignorant for a second and imagine how annoying that is?
.

Mötley

That is what I have always done instead of blowing up forums..,

There is technically enough work on this site to build a server without knowing how to script.

Even myself would feel dumb to not dig on this site on something that is already posted.

Faster work less wait. More scripting capabilities

KAKAN

Message( "[" + Player.ID  + "] " + Chat + Player + ": " + White + Text );It should be Player.Name
oh no

Mötley

#8
Quote from: KAKAN on Mar 05, 2016, 06:38 PMMessage( "[" + Player.ID  + "] " + Chat + Player + ": " + White + Text );It should be Player.Name

That is an addition to label what there Player ID is It is a little helpful, The name is "Player" :)

MacTavish

and if ( Player.Spawned ) it should be if ( Player.IsSpawned )

Grand Hunting Project
Join #SLC, #KAKAN, #Doom, #GHP @LUnet

Retired VC:MP Player/Scripter :P

ysc3839

Quote from: KAKAN on Mar 05, 2016, 06:38 PMMessage( "[" + Player.ID  + "] " + Chat + Player + ": " + White + Text );It should be Player.Name
https://bitbucket.org/stormeus/0.4-squirrel/src/7f2afa936b0ef0caa936752aab6d6d12a170ceb7/CPlayer.cpp?fileviewer=file-view-default#CPlayer.cpp-430

There is a "_tostring" function in CPlayer class. So use "player" in code is OK.
c.GlobalFunc(_SC("_tostring"), &PlayerToString);Sqrat::string PlayerToString(CPlayer * p)
{
return p->GetName();
}

Mötley

Quote from: Kusanagi on Mar 05, 2016, 07:00 PMand if ( Player.Spawned ) it should be if ( Player.IsSpawned )

Thank you,

( Player.Spawned )

is the same as

( Player.IsSpawned )
 
its just not in the wiki
Updated the code

ysc3839

Quote from: Kusanagi on Mar 05, 2016, 07:00 PMand if ( Player.Spawned ) it should be if ( Player.IsSpawned )
You should see the source code.

Mötley

I have looked at the wiki. I mainly tested both functions, both worth the same exact way. Thank you though

kennedyarz

SLC  you know that the wifi does not work? it is useless, as there is very crazy things, first ban of the function, another function kick, no recording function, there is almost nothing better serves the wiki not update.