Quote:
Originally Posted by GrO
Nice work, thanks.
But what, if I want my mp_buytime to stay at 0.25?
|
1.
PHP Code:
// on plugin start
public OnPluginStart() {
mp_buytime = FindConVar("mp_buytime"); //find a cvar
buytime = GetConVarFloat(mp_buytime); //find value and memorize
HookConVarChange(mp_buytime, ConVarChanged); //intercept value change
}
// on map start
public OnMapStart() {
if(buy_relive_enabled)
SetConVarFloat(mp_buytime, 1440.0, true); //A new value
}
//when the value changes
public ConVarChanged(Handle:convar, const String:oldValue[], const String:newValue[]) {
buytime = GetConVarFloat(mp_buytime); //find value and memorize
if(buy_relive_enabled)
SetConVarFloat(mp_buytime, 1440.0, true); //A new value
}
// on plugin stoped or disabled
public OnPluginEnd() {
SetConVarFloat(mp_buytime, buytime, true); // Set cvar mp_buytime to default
}
Thus, we obtain the following: buyzone always available
2.
PHP Code:
public OnPluginStart() {
HookEvent("round_freeze_end", EventFreezeEnd, EventHookMode_Post); // hook "Freeze End" event
HookEvent("round_end", EventRoundEnd, EventHookMode_Post); // hook "Round End" event
}
//"Freeze End" event
public Action:EventFreezeEnd(Handle:event, const String:name[], bool:dontBroadcast) {
StopBuyTimer(BuyTimer, 0); // remove old buy timer
BuyTimer = CreateTimer(buytime * 60.0, StopBuyTimer, 0); // create new buy timer
}
// "Round End" event
public Action:EventRoundEnd(Handle:event, const String:name[], bool:dontBroadcast) {
StopBuyTimer(BuyTimer, 0); // Remove buy timer
}
public OnGameFrame() {
if(BuyTimer != INVALID_HANDLE)
return;
// if buytimer == 0.0
for(new i=1; i<=MaxClients; i++) {
SetEntProp(i, Prop_Send, "m_bInBuyZone", 0); // Block buyzone!
}
}
Thus, we obtain the following: buyzone is blocked
3.
PHP Code:
//on relive command
public Action:Command_Say(client, args) {
PlayerBuyTimer[client] = CreateTimer(buy_relive_buytime, StopBuyTimer, client); // Create individual buy timer
CS_RespawnPlayer(client); //Respawn
}
public OnGameFrame() {
for(new i=1; i<=MaxClients; i++) {
// if individual buytimer > 0
if(PlayerBuyTimer[i] != INVALID_HANDLE)
continue; // <---- blocking does not happen
SetEntProp(i, Prop_Send, "m_bInBuyZone", 0); // block buyzone
}
}
Thus, players can buy items
-----------------
Other methods, I do not know