Помогите исправить (Emp-Nade)

Тема в разделе "Программирование / Скриптинг", создана пользователем ololoex, 2 май 2015.

  1. ololoex

    ololoex

    Сообщения:
    49
    Симпатии:
    18
    Помогите исправить ошибки
    Исходник:
    Код:
    #pragma semicolon 1 
    
    #include <sourcemod> 
    #include <sdktools> 
    #include <cstrike> 
    #include <smlib> 
    #include <sdkhooks> 
    
    #define PLUGIN_VERSION "1.0" 
    
    #define MAX_WEAPON_NAME 80 
    
    new gGlow1; 
    new gHalo1; 
    new gLaser1; 
    new gSmoke1; 
    
    new Float:g_iClientSpeed[MAXPLAYERS+1]; 
    
    new GiveCountDown = -1; 
    
    new String:emp_sound[] = "emp/emp_ex.mp3"; 
    
    public Plugin:myinfo = 
    { 
    	name = "Ze: EMP", 
    	author = "Zipcore", 
    	description = "", 
    	version = PLUGIN_VERSION, 
    	url = "zipcore#googlemail.com" 
    }; 
    
    public OnPluginStart() 
    { 
    	HookEvent("round_start", Event_OnRoundStart); 
    	HookEvent("player_spawn", Event_OnPlayerSpawn); 
    } 
    
    public OnMapStart() 
    { 
    	CreateTimer(1.0, Timer_Give, 0, TIMER_REPEAT|TIMER_FLAG_NO_MAPCHANGE); 
    	gGlow1 = PrecacheModel("sprites/blueglow2.vmt", true); 
    	gHalo1 = PrecacheModel("materials/sprites/halo01.vmt"); 
    	gLaser1 = PrecacheModel("materials/sprites/laser.vmt"); 
    	gSmoke1 = PrecacheModel("materials/effects/fire_cloud1.vmt"); 
    } 
    
    public OnConfigsExecuted() 
    { 
    	decl String:buffer[255]; 
    	PrecacheSound(emp_sound, true); 
    	Format(buffer, sizeof(buffer), "sound/%s", emp_sound); 
    	AddFileToDownloadsTable(buffer); 
    } 
    
    //
    public OnEntityCreated(entity, const String:classname[]) 
    { 
    	if (StrEqual(classname, "hegrenade_projectile")) 
    	{ 
    		CreateTimer(1.2, Timer_Boom, entity, TIMER_FLAG_NO_MAPCHANGE); 
    	} 
    } 
    
    public Action:Event_OnPlayerSpawn(Handle:event, const String:name[], bool:dontBroadcast) 
    { 
    	new client = GetClientOfUserId(GetEventInt(event, "userid")); 
    	g_iClientSpeed[client] = 1.0; 
    	ClientUpdateSpeed(client); 
    
    	return Plugin_Continue; 
    } 
    
    public Action:Event_OnRoundStart(Handle:event, const String:name[], bool:dontBroadcast) 
    { 
    	for (new i=1;i<MAXPLAYERS;i++) 
    	{ 
    		g_iClientSpeed[i] = 1.0; 
    	} 
    	GiveCountDown = 31; 
    	return Plugin_Continue; 
    } 
    
    public Action:Timer_Give(Handle:Timer, any:client) 
    { 
    	GiveCountDown--; 
    	if(GiveCountDown == 0) 
    	{ 
    		for (new i=1;i<MAXPLAYERS;i++) 
    		{ 
    			if (IsValidClient(i))  
    			{ 
    				if (IsPlayerAlive(i) && GetClientTeam(i) == CS_TEAM_CT) 
    				{ 
    					GivePlayerItem(i, "weapon_hegrenade"); 
    				} 
    			} 
    		} 
    	} 
    	if(4 > GiveCountDown > 0) 
    	{ 
    		for (new i=1;i<MAXPLAYERS;i++) 
    		{ 
    			if (IsValidClient(i))  
    			{ 
    				if (IsPlayerAlive(i) && GetClientTeam(i) == CS_TEAM_CT) 
    				{ 
    					PrintCenterText(i, "%d", GiveCountDown); 
    				} 
    			} 
    		} 
    	} 
    	return Plugin_Handled; 
    } 
    
    public Action:Timer_Boom(Handle:Timer, any:entity)
    { 
    	if(IsValidEntity(entity)) 
    	{ 
    		EmitSoundToAll(emp_sound, entity, SNDCHAN_AUTO, SNDLEVEL_GUNFIRE); 
    
    		decl Float:entityposition[3]; 
    		GetEntPropVector(entity, Prop_Send, "m_vecOrigin", entityposition); 
    
    		entityposition[2] += 20; 
    
    		DrawIonBeam2(entityposition); 
    		TE_SetupBeamRingPoint(entityposition, 0.0, 500.0, gGlow1, gHalo1, 0, 0, 0.5, 10.0, 7.0, {255, 0, 0, 255}, 0, 0); 
    		TE_SendToAll(); 
    		TE_SetupBeamRingPoint(entityposition, 0.0, 500.0, gGlow1, gHalo1, 0, 0, 0.7, 10.0, 7.0, {255, 0, 0, 255}, 0, 0); 
    		TE_SendToAll(); 
    		TE_SetupBeamRingPoint(entityposition, 0.0, 500.0, gGlow1, gHalo1, 0, 0, 0.9, 10.0, 7.0, {255, 0, 0, 255}, 0, 0); 
    		TE_SendToAll(); 
    		TE_SetupBeamRingPoint(entityposition, 0.0, 500.0, gGlow1, gHalo1, 0, 0, 1.4, 10.0, 7.0, {255, 0, 0, 255}, 0, 0); 
    		TE_SendToAll(); 
    
    		new laserent = CreateEntityByName("point_tesla"); 
    		DispatchKeyValue(laserent, "m_flRadius", "70.0"); 
    		DispatchKeyValue(laserent, "m_SoundName", "DoSpark"); 
    		DispatchKeyValue(laserent, "beamcount_min", "42"); 
    		DispatchKeyValue(laserent, "beamcount_max", "62"); 
    		DispatchKeyValue(laserent, "texture", "sprites/physbeam.vmt"); 
    		DispatchKeyValue(laserent, "m_Color", "255 255 255"); 
    		DispatchKeyValue(laserent, "thick_min", "10.0"); 
    		DispatchKeyValue(laserent, "thick_max", "11.0"); 
    		DispatchKeyValue(laserent, "lifetime_min", "0.3"); 
    		DispatchKeyValue(laserent, "lifetime_max", "0.3"); 
    		DispatchKeyValue(laserent, "interval_min", "0.1"); 
    		DispatchKeyValue(laserent, "interval_max", "0.2"); 
    		DispatchSpawn(laserent); 
    
    		TeleportEntity(laserent, entityposition, NULL_VECTOR, NULL_VECTOR); 
    		//
    		AcceptEntityInput(laserent, "TurnOn");  
    		AcceptEntityInput(laserent, "DoSpark"); 
    
    		for (new i = 1; i < MAXPLAYERS ; i++) 
    		{ 
    			if (IsValidClient(i))  
    			{ 
    				if (IsPlayerAlive(i) && GetClientTeam(i) == CS_TEAM_T) 
    				{ 
    					if(Entity_InRange(entity, i, 150.0)) 
    					{ 
    						ClientDecSpeed(i, 0.45); 
    
    						CreateTimer(5.5, Timer_ResetSpeed, i, TIMER_FLAG_NO_MAPCHANGE); 
    					} 
    					else if(Entity_InRange(entity, i, 200.0)) 
    					{ 
    						ClientDecSpeed(i, 0.45); 
    
    						CreateTimer(4.5, Timer_ResetSpeed, i, TIMER_FLAG_NO_MAPCHANGE); 
    					} 
    					else if(Entity_InRange(entity, i, 300.0)) 
    					{ 
    						ClientDecSpeed(i, 0.45); 
    
    						CreateTimer(3.5, Timer_ResetSpeed, i, TIMER_FLAG_NO_MAPCHANGE); 
    					} 
    					else if(Entity_InRange(entity, i, 350.0)) 
    					{ 
    						ClientDecSpeed(i, 0.45); 
    
    						CreateTimer(2.5, Timer_ResetSpeed, i, TIMER_FLAG_NO_MAPCHANGE); 
    					} 
    				} 
    			} 
    		} 
    		AcceptEntityInput(entity,"kill"); 
    	} 
    	return Plugin_Handled; 
    } 
    
    ClientIncSpeed(client, Float:speed) 
    { 
    	g_iClientSpeed[client] += speed; 
    	ClientUpdateSpeed(client); 
    } 
    
    ClientDecSpeed(client, Float:speed) 
    { 
    	g_iClientSpeed[client] -= speed; 
    	ClientUpdateSpeed(client); 
    } 
    
    ClientUpdateSpeed(client) 
    { 
    	if(g_iClientSpeed[client] < 0.30) 
    	{ 
    		SetEntPropFloat(client, Prop_Data, "m_flLaggedMovementValue", 0.30); 
    	} 
    	else if(g_iClientSpeed[client] > 1.5) 
    	{ 
    		SetEntPropFloat(client, Prop_Data, "m_flLaggedMovementValue", 1.5); 
    	} 
    	else 
    	{ 
    		SetEntPropFloat(client, Prop_Data, "m_flLaggedMovementValue", g_iClientSpeed[client]); 
    	} 
    } 
    
    public DrawIonBeam2(Float:startPosition[3]) 
    { 
    	decl Float:position[3]; 
    	position[0] = startPosition[0]; 
    	position[1] = startPosition[1]; 
    	position[2] = startPosition[2] + 1500.0;  
    
    	TE_SetupBeamPoints(startPosition, position, gLaser1, 0, 0, 0, 0.15, 25.0, 25.0, 0, 1.0, {255, 0, 0, 255}, 3 ); 
    	TE_SendToAll(); 
    	position[2] -= 1490.0; 
    	TE_SetupSmoke(startPosition, gSmoke1, 10.0, 2); 
    	TE_SendToAll(); 
    	TE_SetupGlowSprite(startPosition, gGlow1, 1.0, 1.0, 255); 
    	TE_SendToAll(); 
    } 
    
    public Action:Timer_ResetSpeed(Handle:Timer, any:client) 
    { 
    	if(GiveCountDown < 0) ClientIncSpeed(client, 0.45); 
    	return Plugin_Handled; 
    } 
    
    bool:IsValidClient(client)  
    { 
    	if( client <= 0 ) 
    		return false; 
    
    	if( client > GetMaxClients() ) 
    		return false; 
    
    	if( !IsClientConnected(client) ) 
    		return false; 
    
    	if( !IsClientInGame(client) ) 
    		return false; 
    
    
    	return true; 
    }

    Error log:
    Код:
    L 05/02/2015 - 20:11:50: [SM] Native "GetEntPropVector" reported: Property "m_vecOrigin" not found (entity 70/cs_player_manager)
    L 05/02/2015 - 20:11:50: [SM] Displaying call stack trace for plugin "emp_nade.smx":
    L 05/02/2015 - 20:11:50: [SM]   [0]  Line 125, emp_nade.sp::Timer_Boom()
     
  2. SourceSamil

    SourceSamil

    Сообщения:
    121
    Симпатии:
    24
    Замени if(IsValidEntity(entity))
    На if( entity != INVALID_ENT_REFERENCE && IsValidEdict( entity ) && IsValidEntity( entity ) )
     
    Последнее редактирование: 3 май 2015
    ololoex нравится это.
  3. ololoex

    ololoex

    Сообщения:
    49
    Симпатии:
    18
    Ошибки продолжают флудить
     
  4. SourceSamil

    SourceSamil

    Сообщения:
    121
    Симпатии:
    24
    Здесь нужно использовать ф-и EntRefToEntIndex и EntIndexToEntRef
    (Спасибо Reiko1231)
     
    ololoex и AlmazON нравится это.