AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   float problem with write_coord() (https://forums.alliedmods.net/showthread.php?t=245016)

Dark_Siders 07-27-2014 04:06

float problem with write_coord()
 
I have a problem with using float variables in write_coord().

When i use float variables in write_coord() i get tag mismatch error on compiling.

What is the problem? please help!

bat 07-27-2014 04:20

Re: float problem with write_coord()
 
Post code

Dark_Siders 07-27-2014 04:26

Re: float problem with write_coord()
 
Quote:

Originally Posted by bat (Post 2174507)
Post code

PHP Code:

#include <amxmodx>

#define TE_GUNSHOT 2

new PLUGIN[] = "Gun Shot Effect"
new AUTHOR[] = "LeriCo"
new VERSION[] = "1.0"

new Float:fOrigin[3]

public 
plugin_init()
{
    
register_plugin(PLUGINVERSIONAUTHOR)
    
register_clcmd("say /gunshot""GunShotFunc"0)
}

public 
GunShotFunc(id)
{
    
fOrigin[0] = 312.061096
    fOrigin
[1] = -335.421661
    fOrigin
[2] = -594.627014
    
    message_begin
(MSG_ALLSVC_TEMPENTITY)
    
write_byte(TE_GUNSHOT)
    
write_coord(fOrigin[0])
    
write_coord(fOrigin[1])
    
write_coord(fOrigin[2])
    
message_end()


This is a simple code for testing gunshot effect.

hornet 07-27-2014 04:48

Re: float problem with write_coord()
 
write_coord() is for integers. Use EngFunc_WriteCoord.

HamletEagle 07-27-2014 04:54

Re: float problem with write_coord()
 
Or use floatround to convert them to integers....

bat 07-27-2014 04:56

Re: float problem with write_coord()
 
Yeah Mr.Hornet correсtly written.

Code:

#include <amxmodx>
#include <fakemeta>

#define TE_GUNSHOT 2

new PLUGIN[] = "Gun Shot Effect"
new AUTHOR[] = "LeriCo"
new VERSION[] = "1.0"

new Float:fOrigin[3]

public plugin_init()
{
    register_plugin(PLUGIN, VERSION, AUTHOR)
    register_clcmd("say /gunshot", "GunShotFunc", 0)
}

public GunShotFunc(id)
{
    fOrigin[0] = 312.061096
    fOrigin[1] = -335.421661
    fOrigin[2] = -594.627014
   
    engfunc(EngFunc_MessageBegin, MSG_ALL, SVC_TEMPENTITY, fOrigin, 0)
    write_byte(TE_GUNSHOT)
    engfunc(EngFunc_WriteCoord, fOrigin[0])
    engfunc(EngFunc_WriteCoord, fOrigin[1])
    engfunc(EngFunc_WriteCoord, fOrigin[2])
    message_end()
}


hornet 07-27-2014 05:47

Re: float problem with write_coord()
 
Quote:

Originally Posted by HamletEagle (Post 2174519)
Or use floatround to convert them to integers....

Not a good way because your calling extra natives to achieve an incorrect result.


All times are GMT -4. The time now is 13:14.

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