Vice City: Multiplayer

Server Development => Scripting and Server Management => Snippet Showroom => Topic started by: Mötley on Mar 05, 2016, 05:17 PM

Title: onPlayerChat: Example
Post by: Mötley on Mar 05, 2016, 05:17 PM
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;

}

Title: Re: onPlayerChat: Example
Post by: . on Mar 05, 2016, 05:21 PM
You do know that there's a Wiki for that? Are we seriously going to create a topic for every module function?
Title: Re: onPlayerChat: Example
Post by: Mötley on Mar 05, 2016, 05:28 PM
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
Title: Re: onPlayerChat: Example
Post by: . on Mar 05, 2016, 05:39 PM
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.
Title: Re: onPlayerChat: Example
Post by: Mötley on Mar 05, 2016, 05:43 PM
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.
Title: Re: onPlayerChat: Example
Post by: . on Mar 05, 2016, 05:46 PM
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?
Title: Re: onPlayerChat: Example
Post by: Mötley on Mar 05, 2016, 05:51 PM
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
Title: Re: onPlayerChat: Example
Post by: KAKAN on Mar 05, 2016, 06:38 PM
Message( "[" + Player.ID  + "] " + Chat + Player + ": " + White + Text );It should be Player.Name
Title: Re: onPlayerChat: Example
Post by: Mötley on Mar 05, 2016, 06:49 PM
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" :)
Title: Re: onPlayerChat: Example
Post by: MacTavish on Mar 05, 2016, 07:00 PM
and if ( Player.Spawned ) it should be if ( Player.IsSpawned )
Title: Re: onPlayerChat: Example
Post by: ysc3839 on Mar 05, 2016, 07:02 PM
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();
}
Title: Re: onPlayerChat: Example
Post by: Mötley on Mar 05, 2016, 07:39 PM
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
Title: Re: onPlayerChat: Example
Post by: ysc3839 on Mar 05, 2016, 07:53 PM
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.
Title: Re: onPlayerChat: Example
Post by: Mötley on Mar 05, 2016, 08:06 PM
I have looked at the wiki. I mainly tested both functions, both worth the same exact way. Thank you though
Title: Re: onPlayerChat: Example
Post by: kennedyarz on Mar 17, 2016, 08:19 PM
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.