AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   [HelpREQ] How can I set up above avarage Round Time and colored text? (https://forums.alliedmods.net/showthread.php?t=75045)

Dores 07-29-2008 15:14

[HelpREQ] How can I set up above avarage Round Time and colored text?
 
Hi all.
I'm a noob with scripting and I just wanted to know this one little thing.
The maximum minutes you can set up the round clock with the
PHP Code:

mp_roundtime 

cvar according to the CS engine is 9-10 (don't remember which one), and I saw plugins that were able to make round time 15 minutes. How did they do that?



Thanks alot for all helpers and especially thanks to ot_207(:mrgreen:),
dor123:up:

ot_207 07-29-2008 15:44

Re: [HelpREQ] How to set chat text colors, roundtime and forwarding
 
This is what you need to use for colored messages
Beware! Before showing the message to the player you must format it

PHP Code:

format(msg,sizeof(msg) -1,"xxx",any...)
colored_msg(id,msg

To change the colores of the font you need to use these characters:
PHP Code:

^x01 -> for normal color
^x03 -> for team color (red for terorwhite for specblue for ct)
^
x04 -> for green color 

Example of usage:
^x03 Make me cry ^x04 yea ^x01 mama

Will apear ( if you are terrorist)-> Make me cry yea mama
PHP Code:

public colored_msg(id,msg[])
{
    
message_begin(MSG_ONEget_user_msgid("SayText"), {0,0,0}, id)
    
write_byte(id)
    
write_string(msg)
    
message_end()


The roundtime more than 10 ... sorry I don't know :|

To register forwards in fakemeta the function is:
PHP Code:

register_forward(FM_PlayerPreThink,"fw_pre"//in plugin init

public fw_pre(id)
{
// do stuff 



Dores 07-29-2008 21:02

Re: [HelpREQ] How to set chat text colors, roundtime and forwarding
 
Quote:

Originally Posted by ot_207 (Post 661132)
This is what you need to use for colored messages
Beware! Before showing the message to the player you must format it

PHP Code:

format(msg,sizeof(msg) -1,"xxx",any...)
colored_msg(id,msg

To change the colores of the font you need to use these characters:
PHP Code:

^x01 -> for normal color
^x03 -> for team color (red for terorwhite for specblue for ct)
^
x04 -> for green color 

Example of usage:
^x03 Make me cry ^x04 yea ^x01 mama

Will apear ( if you are terrorist)-> Make me cry yea mama
PHP Code:

public colored_msg(id,msg[])
{
    
message_begin(MSG_ONEget_user_msgid("SayText"), {0,0,0}, id)
    
write_byte(id)
    
write_string(msg)
    
message_end()


The roundtime more than 10 ... sorry I don't know :|

To register forwards in fakemeta the function is:
PHP Code:

register_forward(FM_PlayerPreThink,"fw_pre"//in plugin init
 
public fw_pre(id)
{
// do stuff 



1. How come "mama" is orange if ^x01 is normal color?

2. Here is what I did:
PHP Code:

new msg[250];
format(msg249"^x04[XXX]^x03:")
colored_msg(idmsg// Compiler says that there's argument type mismatch on argument 2 (msg)
return 1;
 
public 
colored_msg(idmsg)
{
message_begin(MSG_ONEget_user_msgid("SayText"), {0,0,0}, id
write_byte(id
write_string(msg// Same here, compiler says argument type mismatch
message_end() 
}
 
/* Then I want to use colored_msg to put colored "[XXX]" at the beginning of the text */
 
public function(id)
{
        
colored_msg(id"^x03Text text text..."// Compiler says it again, argument type mismatch on argument 2 ("^x03Text text text...")


Why did I do wrong? Is it because I didn't pressed space after the ^x04[XXX] and just skipped to ^x04[XXX]^x03:...?

About forward, I didn't ment how to register, that thing I already knew.
What I ment is why should I forward? What does it do? What does PreThink and PostTHink and stuff like that mean?
If you could find any guides/tutorials or simply explain to me those things I will be gratefull (also I added karma to you :wink:)

Thank you so much for the help you just made my day, well night,
dor123:up:

danielkza 07-30-2008 00:16

Re: [HelpREQ] How to set chat text colors, roundtime and forwarding
 
'msg' is an array,so the argument declaration must be 'msg[]'.

ot_207 07-30-2008 03:32

Re: [HelpREQ] How to set chat text colors, roundtime and forwarding
 
Quote:

Originally Posted by dor123 (Post 661305)
About forward, I didn't ment how to register, that thing I already knew.
What I ment is why should I forward? What does it do? What does PreThink and PostTHink and stuff like that mean?
If you could find any guides/tutorials or simply explain to me those things I will be gratefull (also I added karma to you :wink:)

So, every forward has its own purpose.
The forwards are functions which are called when a particular event happens.

There are 3 types of forwards
event forwards -> example "Damage", "CurWeapon" etc...
To register these events use ->
PHP Code:

register_event() 

The list of most events that you can hook is -> Half Life Game Events

As example: I will give the CurWeapon event.
Curweapon is an event which is called when a player swiches weapons, shoots weapons, and even reloads.
When one of these actions happen, the event is called with certain parameters.
That is why when example a player has changed a weapon you need to hook the Curweapon event this way ->

PHP Code:

register_event("CurWeapon","my_func","b","1=1"

1 = 1 that means that weapon is active

Fakemeta forwards ->

Allows a lot of forwards which can be very very helpfull.
Example: FM_PlayerPreThink, FM_Think, FM_EmitSound
Code:

enum {
        FM_PrecacheModel = 1,                // int )        (const szModel[])
        FM_PrecacheSound,                // int )        (const szSound[])
        FM_SetModel,                        // void )        (ent, const szModel[])
        FM_ModelIndex,                        // int )        (const szModel[])
        FM_ModelFrames,                        // int )        (iModelIndex)
        FM_SetSize,                        // void )        (ent, const Float:fMins[3], const Float:fMaxs[3])
        FM_ChangeLevel,                        // void )        (szMap[], szSomething[])
        FM_VecToYaw,                        // float )        (const Float:fVector[3])
        FM_VecToAngles,                        // void )        (const Float:fVectorIn[3], Float:fVectorOut[3])
        FM_MoveToOrigin,                // void )        (ent, const Float:fGoal[3], Float:fDistance, iMoveType)
        FM_ChangeYaw,                        // void )        (ent)
        FM_ChangePitch,                        // void )        (ent)
        FM_FindEntityByString,                // edict )        (entStartSearchAfter, const szField[], const szValue[])
        FM_GetEntityIllum,                // int )        (ent)
        FM_FindEntityInSphere,                // edict )        (ent, const Float:fVector[3], Float:fRadius)
        FM_FindClientInPVS,                // edict )        (id)
        FM_EntitiesInPVS,                // edict )        (ent)
        FM_MakeVectors,                        // void )        (const Float:fVector[3])
        FM_AngleVectors,                // void )        (const Float:fVec[3], Float:fForward[3], Float:fRight[3], Float:fUp[3])
        FM_CreateEntity,                // edict )        ()
        FM_RemoveEntity,                // void )        (ent)
        FM_CreateNamedEntity,                // edict )        (iClassname)
        FM_MakeStatic,                        // void )        (ent)
        FM_EntIsOnFloor,                // int )        (ent)
        FM_DropToFloor,                        // int )        (ent)
        FM_WalkMove,                        // int  )        (ent, Float:fYaw, Float:fDist, iMode)
        FM_SetOrigin,                        // void )        (ent, const Float:fOrigin[3])
        FM_EmitSound,                        // void )        (ent, iChannel, const szSample[], Float:fVolume, Float:fAttenuation, iFlags, iPitch)
        FM_EmitAmbientSound,                // void )        (ent, Float:fOrigin[3], const szSample[], Float:fVolume, Float:fAttenuation, iFlags, iPitch)
        FM_TraceLine,                        // void )        (const Float:fV1[3], const Float:fV2[3], iNoMonsters, entToSkip, tr)
        FM_TraceToss,                        // void )        (ent, entToIgnore, tr)
        FM_TraceMonsterHull,                // int )        (ent, const Float:fV1, const Float:fV2, iNoMonsters, entToSkip, tr)
        FM_TraceHull,                        // void )        (const Float:fV1[3], const Float:fV2[3], iNoMonsters, iHullNumber, entToSkip, tr)
        FM_TraceModel,                        // void )        (const Float:fV1[3], const Float:fV2[3], iHullNumber, ent, tr)
        FM_TraceTexture,                // char )        (entTexture, const Float:fV1[3], const Float:fV2[3])
        FM_TraceSphere,                        // void )        (const Float:fV1[3], const Float:fV2[3], iNoMonsters, Float:fRadius, entToSkip, tr)
        FM_GetAimVector,                // void )        (ent, Float:fSpeed, Float:fReturn[3])
        FM_ParticleEffect,                // void )        (const Float:fOrigin[3], const Float:fDir[3], Float:fColor, Float:fCount)
        FM_LightStyle,                        // void )        (iStyle, szVal[])
        FM_DecalIndex,                        // int )        (const szName[])
        FM_PointContents,                // int )        (const Float:fOrigin[3])
        FM_MessageBegin,                // void )        (iMsg_Dest, iMsg_Type, const Float:fOrigin[3], ent)
        FM_MessageEnd,                        // void )        ()
        FM_WriteByte,                        // void )        (iValue)
        FM_WriteChar,                        // void )        (iValue)
        FM_WriteShort,                        // void )        (iValue)
        FM_WriteLong,                        // void )        (iValue)
        FM_WriteAngle,                        // void )        (Float:fValue)
        FM_WriteCoord,                        // void )        (Float:fValue)
        FM_WriteString,                        // void )        (const szValue[])
        FM_WriteEntity,                        // void )        (iValue)
        FM_CVarGetFloat,                // float )        (const szCvar[])
        FM_CVarGetString,                // char )        (const szCvar[])
        FM_CVarSetFloat,                // void )        (const szCvar[], Float:fValue)
        FM_CVarSetString,                // void )        (const szCvar[], szValue[])
        FM_FreeEntPrivateData,                // void )        (ent)
        FM_SzFromIndex,                        // char )        (iString)
        FM_AllocString,                        // int )        (const szValue[])
        FM_RegUserMsg,                        // int )        (szName[], iSize)
        FM_AnimationAutomove,                // void )        (const ent, Float:fTime)
        FM_GetBonePosition,                // void )        (const ent, iBone, Float:fOrigin[3], Float:fAngle[3])
        FM_GetAttachment,                // void        )        (const ent, iAttachment, Float:fOrigin[3], Float:fAngle[3])
        FM_SetView,                        // void )        (const ent, const entView)
        FM_Time,                        // float )        ()
        FM_CrosshairAngle,                // void )        (const ent, Float:fPitch, Float:fYaw)
        FM_FadeClientVolume,                // void )        (const ent, iFadePercent, iFadeOutSeconds, iHoldTime, iFadeInSeconds)
        FM_SetClientMaxspeed,                // void )        (const ent, Float:fMaxSpeed)
        FM_CreateFakeClient,                // edict )        (const szNetName[])
        FM_RunPlayerMove,                // void )        (const entFakeClient, Float:fViewAngles[3], Float:fForwardmove, Float:fSidemove, Float:fUpmove, iButtons, iImpulse, i_mSec)
        FM_NumberOfEntities,                // int )        ()
        FM_StaticDecal,                        // void )        (const Float:fOrigin[3], iDecalIndex, iEntityIndex, iModelIndex)
        FM_PrecacheGeneric,                // int )        (szString[])
        FM_BuildSoundMsg,                // void )        (ent, iChannel, const szSample[], Float:fVolume, Float:fAttenuation, iFlags, iPitch, iMsg_Dest, iMsg_Type, const Float:fOrigin[3], ent)
        FM_GetPhysicsKeyValue,                // char )        (const ent, const szKey[])
        FM_SetPhysicsKeyValue,                // void )        (const ent, const szKey[], const szValue[])
        FM_GetPhysicsInfoString,        // char )        (const ent)
        FM_PrecacheEvent,                // int )        (iType, const szEvent[])
        FM_PlaybackEvent,                // void )        (iFlags, const entInvoker, iEventIndex, Float:fDelay, Float:fOrigin[3], Float:fAngles[3], Float:fParam1, Float:fParam2, iParam1, iParam2, bool:bParam1, bool:bParam2)
        FM_CheckVisibility,                // int )        (const ent, iSet)
        FM_GetCurrentPlayer,                // int )        ()
        FM_CanSkipPlayer,                // int )        (const ent)
        FM_SetGroupMask,                // void )        (iMask, iOp)
        FM_Voice_GetClientListening,        // bool )        (iReceiver, iSender)
        FM_Voice_SetClientListening,        // bool )        (iReceiver, iSender, bool:bListen)
        FM_InfoKeyValue,                // char )        (szInfoBuffer[], szKey[])
        FM_SetKeyValue,                        // void )        (szInfoBuffer[], szKey[], szValue[])
        FM_SetClientKeyValue,                // void )        (iClientIndex, szInfoBuffer[], szKey[], szValue[])
        FM_GetPlayerAuthId,                // char )        (ent)
        FM_GetPlayerWONId,                // char )        (ent)
        FM_IsMapValid,                        // int )        (szFileName[])


        FM_Spawn,                        // int )        (ent)
        FM_Think,                        // void )        (ent)
        FM_Use,                                // void )        (entUsed, entOther)
        FM_Touch,                        // void )        (entTouched, entOther)
        FM_Blocked,                        // void )        (entBlocked, entOther)
        FM_KeyValue,                        // void )        (keyvalue, kvd_id)
        FM_SetAbsBox,                        // void )        (ent)
        FM_ClientConnect,                // bool )        (ent, const szName[], const szAddress[], const szRejectReason[128])
       
        FM_ClientDisconnect,                // void )        (ent)
        FM_ClientKill,                        // void )        (ent)
        FM_ClientPutInServer,                // void )        (ent)
        FM_ClientCommand,                // void )        (ent)

        FM_ServerDeactivate,                // void )        ()

        FM_PlayerPreThink,                // void )        (ent)
        FM_PlayerPostThink,                // void )        (ent)

        FM_StartFrame,                        // void )        ()
        FM_ParmsNewLevel,                // void )        ()
        FM_ParmsChangeLevel,                // void )        ()

        // Returns string describing current .dll.  E.g., TeamFotrress 2, Half-Life
        FM_GetGameDescription,                // char )        ()

        // Spectator funcs
        FM_SpectatorConnect,                // void )        (ent)
        FM_SpectatorDisconnect,                // void )        (ent)
        FM_SpectatorThink,                // void )        (ent)

        // Notify game .dll that engine is going to shut down.  Allows mod authors to set a breakpoint.
        FM_Sys_Error,                        // void )        (const szError[])

        FM_PM_FindTextureType,                // char )        (szType[])
        FM_RegisterEncoders,                // void )        ()

        // Enumerates player hulls.  Returns 0 if the hull number doesn't exist, 1 otherwise

        // Create baselines for certain "unplaced" items.
        FM_CreateInstancedBaseline,        // void )        ()
        FM_AllowLagCompensation,        // int )        ()
       
        FM_AlertMessage,                // void )        (AlertType:aType, szBuffer[])

        // NEW_DLL_FUNCTIONS:
        FM_OnFreeEntPrivateData,        // void )        (ent)
        FM_GameShutdown,                // unknown )        ()
        FM_ShouldCollide,                // unknown )        (entTouched, entOther)

        // LATE ADDITIONS (v1.71)
        FM_ClientUserInfoChanged,        // void )        (ent, szInfo[])
       
        // LATE ADDITIONS (v1.75)
        FM_UpdateClientData,                // void )        (const ent, iSendWeapons, cd_handle)
        FM_AddToFullPack,                // int )        (entState, e, ent, host, iHostFlags, iPlayer, pSet)
        FM_CmdStart,                        // void )        (const ent, uc_handle, seed)
        FM_CmdEnd,                        // void )        (const ent)
        FM_CreateInstBaseline,                // int )        (classname, baseline)
        FM_CreateBaseline,                // void )        (iPlayer, i_eIndex, baseline, ent, iPlayerModelIndex, Float:fMins[3], Float:fMaxs[3])
        FM_GetInfoKeyBuffer,                // char )        (ent)
        FM_ClientPrintf                // void )        (ent, type, const szMsg[])
};

This is from amxx wiki.

The forward FM_EmitSound takes place when at an origin a sound is emited.
For example I will give the moment when a he grenade explodes.
It will produce a sound that will make a player know that it has kaboomed.
When the sound is produced or better said before that.
The forward FM_EmitSound is called with these paramaters (ent, iChannel, const szSample[], Float:fVolume, Float:fAttenuation, iFlags, iPitch)
To get an accurate forward you must check almost all the paramaters.
ent = hegrenade
iChannel = the channel which was chosen (not important)
szSample[] = the sound that will be emited
The rest are some other stuff that I didn't use...

FM_PlayerPreThink is a function which takes place repetetively on an ammount of x miliseconds.
The same for postThink. But the diference is that these ones take place one after another.
Then the func will execute this way: -> PRETHINK -> POSTHINK -> PRETHINK ...

And the last Hamsandwich forwards -> RegisterHam(Ham_XXX,entclassname[],"function",post=0)
The same as fakemeta ;).

Dores 07-30-2008 06:47

Re: [HelpREQ] How to set chat text colors, roundtime and forwarding
 
Quote:

Originally Posted by danielkza (Post 661385)
'msg' is an array,so the argument declaration must be 'msg[]'.

Ok, thanks alot!


Quote:

Originally Posted by ot_207
FM_PlayerPreThink is a function which takes place repetetively on an ammount of x miliseconds.
The same for postThink. But the diference is that these ones take place one after another.
Then the func will execute this way: -> PRETHINK -> POSTHINK -> PRETHINK ...

Ok, but what does it do besides that? or that is the main action the function do? how do I use it? when? like the following?
PHP Code:

register_forward(FM_PlayerPreThink"my_func"

Is PlayerPre/PostThink an event? If it is, what event is it?
Why should I use it? Could you give me an example of things that would be good to have them working repetetively on an amount of x miliseconds?

And if Hamsandwich is same as FakeMeta, why should I use it?

Sorry for all the questions and thanks again,
dor123:up:

ot_207 07-30-2008 07:04

Re: [HelpREQ] How to set chat text colors, roundtime and forwarding
 
Quote:

Originally Posted by dor123 (Post 661514)
Ok, but what does it do besides that? or that is the main action the function do? how do I use it? when? like the following?
PHP Code:

register_forward(FM_PlayerPreThink"my_func"

Is PlayerPre/PostThink an event? If it is, what event is it?

Why should I use it? Could you give me an example of things that would be good to have them working repetetively on an amount of x miliseconds?

There are forwards which take place one a specific event like FM_EmitSound.

And There are forwards which repeat themselves on an entity->
There are 3 forwards which I have used that repeat themselves ->
These are (from fakemeta) : FM_PlayerPreThink FM_PlayerPostThink, and FM_Think

That means that an entity (FM_Think) / player (FM_player...) is thinking.
It is a forward which is called by the engine every 0.0... miliseconds.
The diference between them is that FM_Think is used for entities and FM_Player... takes place for players.
These thinks are a tasks which repeats itself the way I said a bit earlyer.

Hamsandwich is good becouse it offers a lot of functions which are the things that fakemeta didn't have.
For example: Ham_TakeDamage is one of the best functions (at least I think so :D) that is offered by that module.

My opinion is that the combination of Fakemeta and Hamsandwich = The BEST!!!

Dores 07-30-2008 13:17

Re: [HelpREQ] How to set chat text colors, roundtime and forwarding
 
Ok, thanks alot ot_207 you helped me alot.
I think i''ll start with the basics before going to forwards, FakeMeta and HamSandwich. I'm too noob for those ;) I'll leave that to the pros (like you) for now untill I get the hang of things.

Oh and btw, you didn't answered me why "mama" was orange if you put ^x01 next to it, and if ^x01 is normal color?

I edited to main post for the stuff you helped me with them. Now all left is round time :)



Thanks alot and don't think you wasted your time on me for nothing, i'll use it somewhen,
dor123:up:

ot_207 07-30-2008 15:10

Re: [HelpREQ] How can I set up above avarage Round Time?
 
It is orange/the chatcolor that you have
That means when your chat color is white for example the color that will apear will be white ( normal chat color ).
The default settings in cs makes your chat look like a yellow to orange.
That is why it will apear orange.

Dores 07-30-2008 17:02

Re: [HelpREQ] How can I set up above avarage Round Time?
 
I already edited the main post but I'm still having problems.

I did everything perfectly fine:
PHP Code:

public plugin_init()
{
register_clcmd("say /help""player_help", -1"")
}
 
public 
player_help(id)
{
new 
msg[250];
format(msg249"^x04[XXX]^x03:")
colored_msg(idmsg)
set_task(0.2"help")
}
 
public 
colored_msg(idmsg[])
{
message_begin(MSG_ONEget_user_msgid("SayText"), {0,0,0}, id
write_byte(id
write_string(msg
message_end() 
}
 
public 
help(id)
{
colored_msg(id"^x03text text text...")


But when I typed /help while in the game, it showed the green "[XXX]" with the team colored ":" and then when the team colored "text text text..." was supose to come up, the listenserver got crashed or I just got kicked so it closed.
In the console there was this message:
Code:

Host_Error: WriteDest_Parm: not a client
What did I do wrong? What do they mean - not a client?

I want that the colored_msg function will put a green "[XXX]" at the beginning of the text.

Sorry for bothering,
dor123:up:


All times are GMT -4. The time now is 05:36.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.