text
stringlengths 0
692
|
---|
} |
public fwEvGameWillRestartIn() { |
static iPlayers[32], iPlayersNum, i |
get_players(iPlayers, iPlayersNum, "a") |
for (i = 0; i < iPlayersNum; ++i) |
g_bPlayerNonSpawnEvent[iPlayers[i]] = true |
} |
public fwCmdClFullupdate(iPlayerId) { |
g_bPlayerNonSpawnEvent[iPlayerId] = true |
static const szFwFmClientCommandPost[] = "fwFmClientCommandPost" |
g_iFwFmClientCommandPost = register_forward(FM_ClientCommand, szFwFmClientCommandPost, 1) |
return PLUGIN_CONTINUE |
} |
public fwFmClientCommandPost(iPlayerId) { |
unregister_forward(FM_ClientCommand, g_iFwFmClientCommandPost, 1) |
g_bPlayerNonSpawnEvent[iPlayerId] = false |
return FMRES_HANDLED |
} |
public fwPlayerSpawn(iPlayerId) { |
// player spawned |
} |
3. Round Start |
The "Round Start" is happen at the "Freeze Time" end. |
Many of the coders does think that the "Round Start" and "New Round" is the same event and doing a things that is related to the "New Round" in "Round Start" but this is incorrect. Some of the coders especially in the past have used the "RoundTime" event to detect the "Round Start", but again this is inefficient method (the details can be found in the "New Round" section of the article). |
The correct method that can be used to detect the "Round Start" is shown below: |
PHP Code: |
register_logevent("logevent_round_start", 2, "1=Round_Start") |
4. Round End |
The "Round End" is happen right at the moment when one of the teams is completed objectives: all players in the opposite team is killed, all hostages is rescued, time of the round is up, etc. |
Some of the coders does think that the "Round End" and "New Round" is the same event and doing a things that is related to the "New Round" in the "Round End" but this is incorrect. |
The correct method that can be used to detect the "Round End" is shown below: |
PHP Code: |
register_logevent("logevent_round_end", 2, "1=Round_End") |
Still confused? |
Still confused and don't really sure which from the above events should be used in your plugin? Review the below examples that may help you to understand the things better. |
The "New Round" event can be used to move a spawn point entities or to play a music for a players if a freeze time is too long. |
The "Player Spawn" can be used to alter a player's properties like start health, weapons, etc. |
The "Round Start" can be used to create your own "buytime" for a plugins that provide a purchasable items or when you want to create a surprise item. |
The "Round End" can be used to protect a players with a godmode until the "New Round" or to create a quick minigame until the "New Round". |
CVARs |
This quick guide will show you what they are and how they behave. |
Here's a great list of cvars: http://scripting.elxdraco.net/cvarlist/ |
What are they? |
You can think of them as global (sort of) variables. You can retrieve their values, set new values, and also create new cvars. They differ from actual global variables, because you can change cvar values from the console. |
Usage |
You can store all sorts of stuff in your cvars. Typically, they are used to control plugins, turn them on/off, or to hold data temporarily. You can use the flags listed below to modify the behavior of the cvars. |
If you will read the cvar value later on in your script, use pointers. |
Use get_pcvar_flags, get_pcvar_float, get_pcvar_num, or get_pcvar_string. |
Do not use get_cvar_flags, get_cvar_float, get_cvar_num, or get_cvar_string. |
Code: |
register_cvar ( const name[], const string[], flags = 0, Float:fvalue = 0.0 ) |
I haven't found any examples where fvalue is used, so please post if you know what it's for. |
Example Usage: |
Code: |
new cvar_MyCvar // this is a pointer |
new cvar_OtherCvar // this is also a pointer |
public plugin_init() |
{ |
// this cvar has no flags assigned |
cvar_MyCvar = register_cvar("amx_mycvar", "0") |
// this cvar has two flags assigned |
cvar_OtherCvar = register_cvar("amx_other", "1", FCVAR_SPONLY|FCVAR_UNLOGGED) |
} |
public MyFunction() |
{ |
if(get_pcvar_num(cvar_MyCvar)) |
return 1 |
return 0 |
} |
How do they behave? |