AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Cannot find tag mismatch (https://forums.alliedmods.net/showthread.php?t=117882)

r4ndomz 02-05-2010 18:06

Cannot find tag mismatch
 
I cannot find why im getting the errors in line 26 and 47-47.
Both of them use Ownerteam inside the code. Whats the problem?

Its anti-team seems to not be working. Any ideas?

PHP Code:

#include <amxmodx>
#include <hamsandwich>
#include <fakemeta>
#include <cstrike>
#include <engine>

new owner
new Ownerteam

public plugin_init()
{
    
register_plugin("Nade-Slap","1.0","r4nDoMz")
    
register_cvar("nslap_dmg""5")
    
register_touch("grenade""player""touch_nade")
    
register_cvar("amx_nslap""1")
    
RegisterHamHam_Weapon_PrimaryAttack"weapon_hegrenade""Nadethrow"// If the user throws a nade, we get the origin of it in the function
        
RegisterHamHam_Weapon_PrimaryAttack"weapon_flashbang""Nadethrow")
        
RegisterHamHam_Weapon_PrimaryAttack"weapon_smokegrenade""Nadethrow")
}

public 
touch_nade(nadeid)
{

    new 
hitTeam cs_get_user_team(id)
  
    if(
Ownerteam == hitTeam)
    {
        return
    }

    if(!
get_cvar_num("amx_nslap"))
    {
        return
    }

    
entity_set_edict(nadeEV_ENT_aimentid)
    
user_slap(idget_cvar_num("nslap_dmg"), 0)
    
entity_set_int(nadeEV_INT_sequence0)
}



public 
Nadethrow()
{
    
pev(pev_ownerowner)
    
Ownerteam cs_get_user_team(owner)


Code:

//AMXXPC compile.exe
// by the AMX Mod X Dev Team


//// nade-slap.sma
// C:\Documents and Settings\nick\Desktop\compiler1\nade-slap.sma(26) : warning
213: tag mismatch
// C:\Documents and Settings\nick\Desktop\compiler1\nade-slap.sma(46 -- 47) : wa
rning 213: tag mismatch
// Header size:            676 bytes
// Code size:            1400 bytes
// Data size:              752 bytes
// Stack/heap size:      16384 bytes; estimated max. usage=42 cells (168 bytes)
// Total requirements:  19212 bytes
//
// 2 Warnings.
// Done.
//
// Compilation Time: 0.7 sec
// ----------------------------------------

Press enter to exit ...


ConnorMcLeod 02-05-2010 18:08

Re: Cannot find tag mismatch
 
You should learn bases first.
There are a lot of critical errors in your code. Tag mismatch are minor errors.

Seta00 02-05-2010 18:22

Re: Cannot find tag mismatch
 
I've only corrected the tag mismatch warnings, not the critical errors :wink:
PHP Code:

#include <amxmodx>
#include <hamsandwich>
#include <fakemeta>
#include <cstrike>
#include <engine>

new owner
new CsTeams:Ownerteam

public plugin_init()
{
    
register_plugin("Nade-Slap","1.0","r4nDoMz")
    
register_cvar("nslap_dmg""5")
    
register_touch("grenade""player""touch_nade")
    
register_cvar("amx_nslap""1")
    
RegisterHamHam_Weapon_PrimaryAttack"weapon_hegrenade""Nadethrow"// If the user throws a nade, we get the origin of it in the function
    
RegisterHamHam_Weapon_PrimaryAttack"weapon_flashbang""Nadethrow")
    
RegisterHamHam_Weapon_PrimaryAttack"weapon_smokegrenade""Nadethrow")
}

public 
touch_nade(nadeid)
{
    new 
CsTeams:hitTeam cs_get_user_team(id)
  
    if(
Ownerteam == hitTeam)
    {
        return
    }

    if(!
get_cvar_num("amx_nslap"))
    {
        return
    }

    
entity_set_edict(nadeEV_ENT_aimentid)
    
user_slap(idget_cvar_num("nslap_dmg"), 0)
    
entity_set_int(nadeEV_INT_sequence0)
}



public 
Nadethrow()
{
    
pev(pev_ownerowner)
    
Ownerteam cs_get_user_team(owner)



r4ndomz 02-05-2010 18:50

Re: Cannot find tag mismatch
 
Then what are the critical errors?
I did ask why the team thing wasnt working

Seta00 02-05-2010 19:41

Re: Cannot find tag mismatch
 
1) On Nadethrow, pev(pev_owner, owner) should be owner = pev(nade_id, pev_owner). And there's no reason for owner to be a global variable.
2) You should use pcvars.
3) Your logic is in the right way, but in a real situation it gets tricky. What if a player throws a grenade, then another player throws another one before the first grenade hits someone? A think a nice approach will be to store the id of the thrown grenade, then in touch_nade check if the id of the touching grenade matches the id of the thrown nade. Then you check for the players teams.

r4ndomz 02-05-2010 19:52

Re: Cannot find tag mismatch
 
i tried it and it says undefined symbol nade_id?

Seta00 02-05-2010 20:01

Re: Cannot find tag mismatch
 
nade_id was just a placeholder, you have to find the thrown grenade's id and use it.

r4ndomz 02-05-2010 20:02

Re: Cannot find tag mismatch
 
How would i do that?

Should i use:

http://www.amxmodx.org/funcwiki.php?go=func&id=398 --- get_grenade

or

http://www.amxmodx.org/funcwiki.php?go=func&id=369 --- get_grenade_id

get_grenade says this: Gets the grenade is thrown by a user. That doesn't make much sense

Seta00 02-05-2010 20:13

Re: Cannot find tag mismatch
 
You should use get_grenade_id, but it seems not possible to detect the player who fired Ham_Weapon_PrimaryAttack.

Found it: grenade_throw has everything you need.

wrecked_ 02-05-2010 20:14

Re: Cannot find tag mismatch
 
This is from my nadeslap plugin.

PHP Code:

public hfw_NadeThrow(e_NadeThrown)
{
    
peve_NadeThrownpev_originf_ThrowOrigin // Get the origin of the nade right as it is thrown

    
peve_NadeThrownpev_ownerpl_Owner // Get ID of player who throws the nade

    
ownerTeam cs_get_user_teampl_Owner // His team

    
get_user_namepl_Ownersz_ThrowerNamecharsmaxsz_ThrowerName ) ) // His name




All times are GMT -4. The time now is 07:26.

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