Veteran Member
Join Date: Aug 2016
Location: Italy
07-24-2017
, 09:35
Issue with API. (Creating custom LR)
#1
I've done a new LR, using lastrequest API, some days ago was working good, but now apparently without no reason, stopped working well.
When someone try to do the LR GunFight, after chosen the CT the menu disappear, and when there is only 1 CT alive, after doing GunFight, the menu disappeart and the chat says that, there aren't CT for the LR.
the code
Spoiler
PHP Code:
#include <sourcemod>
#include <sdktools>
#include <sdkhooks>
#include <cstrike>
#include <hexstocks>
#include <emitsoundany>
#include <hosties>
#include <lastrequest>
#pragma newdecls required
#pragma semicolon 1
#define PLUGIN_AUTHOR "Hexah"
#define PLUGIN_VERSION "1.00"
//Handle
Menu WeapMenu = null ;
Menu HPMenu = null ;
Handle hTimer = null ;
int LR_GunFight = 0 ;
int LRType = 0 ;
int LR_Guard = 0 ;
int LR_Terror = 0 ;
int iLRHealth = 0 ;
int iDelay = 4 ;
char sLRWeap [ 32 ];
char Sound [ 64 ][ 5 ];
public Plugin myinfo =
{
name = "GunFight LR" ,
author = PLUGIN_AUTHOR ,
description = "" ,
version = PLUGIN_VERSION ,
url = "csitajb.it"
};
//Startup
public void OnPluginStart ()
{
WeapMenu = CreateMenu ( hLRWeapon );
WeapMenu . SetTitle ( "Choose your weapon!" );
WeapMenu . AddItem ( "awp" , "AWP" );
WeapMenu . AddItem ( "m4a1" , "M4A4" );
WeapMenu . AddItem ( "deagle" , "Deagle" );
WeapMenu . AddItem ( "ak47" , "AK47" );
SetMenuExitButton ( WeapMenu , true );
HPMenu = CreateMenu ( hLRHP );
HPMenu . SetTitle ( "Choose the HP" );
HPMenu . AddItem ( "100" , "100" );
HPMenu . AddItem ( "200" , "200" );
HPMenu . AddItem ( "350" , "350" );
HPMenu . AddItem ( "500" , "500" );
SetMenuExitButton ( HPMenu , true );
}
public void OnPluginEnd ()
{
RemoveLastRequestFromList ( OnLRStart , OnLREnd , "GunFight" );
}
public void OnConfigsExecuted ()
{
static bool bAddedLR = false ;
if (! bAddedLR )
{
LR_GunFight = AddLastRequestToList ( OnLRStart , OnLREnd , "GunFight" , false );
bAddedLR = true ;
}
}
public void OnMapStart ()
{
PrecacheSoundAny ( "sound/sm_hosties/noscopestart1.mp3" );
for ( int i = 0 ; i <= 5 ; i ++)if ( i != 0 ) //Need do clean up
{
Format ( Sound [ i - 1 ], sizeof ( Sound []), "sound/timeleft/en/unreal/%isec.mp3" , i );
PrecacheSoundAny ( Sound [ i - 1 ]);
}
}
//Events
public int OnLRStart ( Handle LR_Array , int ArrayIndex )
{
LRType = GetArrayCell ( LR_Array , ArrayIndex , view_as < int >( Block_LRType )); // get this lr from selection
if ( LRType == LR_GunFight )
{
LR_Guard = GetArrayCell ( LR_Array , ArrayIndex , view_as < int >( Block_Guard ));
LR_Terror = GetArrayCell ( LR_Array , ArrayIndex , view_as < int >( Block_Prisoner ));
CheckDataPack ( LR_Array , ArrayIndex );
DisplayMenu ( WeapMenu , LR_Terror , MENU_TIME_FOREVER );
PrintToChat ( LR_Guard , "\x04[SM] \x01The player %N selected to you as a partner in his lastrequest." , LR_Terror );
}
}
public void PreInitializeLR ()
{
for ( int i = 1 ; i <= MaxClients ; i ++)
EmitSoundToAllAny ( Sound [ 4 ]);
StripAllPlayerWeapons ( LR_Guard );
StripAllPlayerWeapons ( LR_Terror );
PrintToHud ( LR_Guard , "5" , 0.9 , - 1.0 , - 1.0 , 255 , 255 , 100 , 100 );
PrintToHud ( LR_Terror , "5" , 0.9 , - 1.0 , - 1.0 , 255 , 255 , 100 , 100 );
PrintToChatAll ( "[SM] LR sta per iniziare!" );
GivePlayerItem ( LR_Guard , "weapon_knife" );
GivePlayerItem ( LR_Terror , "weapon_knife" );
hTimer = CreateTimer ( 1.0 , Timer_CountDown , _ , TIMER_REPEAT );
}
public Action Timer_CountDown ( Handle timer )
{
if ( iDelay == 0 )
{
EmitSoundToAllAny ( "sound/sm_hosties/noscopestart1.mp3" );
GivePlayerItem ( LR_Guard , sLRWeap );
GivePlayerItem ( LR_Terror , sLRWeap );
SetEntityHealth ( LR_Guard , iLRHealth );
SetEntityHealth ( LR_Terror , iLRHealth );
iDelay = 4 ;
InitializeLR ( LR_Terror );
return Plugin_Stop ;
}
char sDelay [ 8 ];
IntToString ( iDelay , sDelay , sizeof ( sDelay ));
iDelay --;
PrintToHud ( LR_Guard , sDelay , 0.9 , - 1.0 , - 1.0 , 255 , 255 , 100 , 100 );
PrintToHud ( LR_Terror , sDelay , 0.9 , - 1.0 , - 1.0 , 255 , 255 , 100 , 100 );
EmitSoundToAllAny ( Sound [ iDelay ]);
return Plugin_Continue ;
}
public int OnLREnd ( int type , int prisioner , int guard )
{
if ( hTimer != null )
{
KillTimer ( hTimer );
}
LR_GunFight = 0 ;
LRType = 0 ;
LR_Guard = 0 ;
LR_Terror = 0 ;
iLRHealth = 0 ;
iDelay = 4 ;
strcopy ( sLRWeap , sizeof ( sLRWeap ), "" );
}
void CheckDataPack ( Handle LR_Array , int ArrayIndex )
{
int LR_Pack_Value = GetArrayCell ( LR_Array , ArrayIndex , view_as < int >( Block_Global1 ));
switch ( LR_Pack_Value )
{
case - 1 :
{
PrintToServer ( "no info included" );
}
}
SetArrayCell ( LR_Array , ArrayIndex , 3 , view_as < int >( Block_Global1 ));
}
//Menu
public int hLRWeapon ( Menu menu , MenuAction action , int param1 , int param2 )
{
if ( action == MenuAction_Select )
{
menu . GetItem ( param2 , sLRWeap , sizeof ( sLRWeap ));
Format ( sLRWeap , sizeof ( sLRWeap ), "weapon_%s" , sLRWeap );
DisplayMenu ( HPMenu , param1 , MENU_TIME_FOREVER );
}
}
public int hLRHP ( Menu menu , MenuAction action , int param1 , int param2 )
{
if ( action == MenuAction_Select )
{
char info [ 16 ];
menu . GetItem ( param2 , info , sizeof ( info ));
iLRHealth = StringToInt ( info );
PreInitializeLR ();
}
}
__________________
Last edited by Papero; 07-24-2017 at 15:05 .