AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   [SOLVED] read_data doesn't return value (https://forums.alliedmods.net/showthread.php?t=278048)

Vit_amin 01-23-2016 17:00

[SOLVED] read_data doesn't return value
 
I Hook Event:
PHP Code:

register_event("DeathMsg""Event_PlayerDeath""a"

My CallBack:
PHP Code:

public Event_PlayerDeath()
{
    
server_print("%d | %d | %d"read_data(0), read_data(1), read_data(2))


But every killing my console output:
Code:

0 | 0 | 0
P.S. This problem begun after when i update Amx Mod X in 1 8.3

Bugsy 01-23-2016 17:16

Re: read_data doesn't return value
 
Works fine for me on my current 1.8.3 build
Code:

0 | 1 | 4
But you should be using 1,2,3 and not 0,1,2

DeathMsg
Structure:
1 = byte KillerID
2 = byte VictimID
3 = byte IsHeadshot
4 = string TruncatedWeaponName

Vit_amin 01-23-2016 17:22

Re: read_data doesn't return value
 
Fixed mistake, however output console too

Bugsy 01-23-2016 17:42

Re: read_data doesn't return value
 
Is there a reason you aren't doing the RoundEndCondition checks in the PlayerDeath forward? Why the 0.1 task?

Vit_amin 01-23-2016 18:31

Re: read_data doesn't return value
 
HOW it's possible ....
Where is my mistake ??????
PHP Code:

public Event_PlayerDeath()
{
    new 
szArgs[2]
    new 
attacker read_data(1)
    new 
client read_data(2)
    
server_print("%d | %d"clientattacker)
    
num_to_str(attackerszArgs1)
    
num_to_str(clientszArgs2)
    
server_print("DEBUG ------------------ %s | Client: %s"szArgs[0], szArgs[1])
    
set_task(0.1"Timer_RoundEndCondition"1024szArgs2)
}

public 
Timer_RoundEndCondition(args[])
{
    
server_print("Attacker: %d | Client: %d"str_to_num(args[0]), str_to_num(args[1]))


Output:
Code:

24 | 3
DEBUG ------------------ 24 | Client: 4
L 01/24/2016 - 01:29:19: "Chet<3><BOT><CT>" killed "[Zombie] Tony<24><BOT><TERRORIST>" with "m4a1"
Attacker: 24 | Client: 4


wickedd 01-23-2016 19:12

Re: read_data doesn't return value
 
First of all, you need to learn how to use the edit button. It's there for a reason. Explain what you're trying to accomplish.

Vit_amin 01-23-2016 19:18

Re: read_data doesn't return value
 
Please read the output to the console
Code:

Debug #1 Client ID (iVictim) 24 | Attacker ID (iKiller) 3
DEBUG ------------------ Client ID (iVictim) 24 | Attacker ID (iKiller) Client: 4
Console Log Output L 01/24/2016 - 01:29:19: "Chet<3><BOT><CT>" killed "[Zombie] Tony<24><BOT><TERRORIST>" with "m4a1"
Attacker: 24 | Client: 4


Bugsy 01-23-2016 20:19

Re: read_data doesn't return value
 
You are overwriting attacker with client:
num_to_str(attacker, szArgs, 1)
num_to_str(client, szArgs, 2)

You are telling it to write attacker into szArgs as a string and the max chars that can fit is 1.
You are then telling it to write client into szArgs as a string and the max chars that can fit is 2.
They are both getting written to szArgs so only the client string is there in the end.

Also, you should not be storing this data as a string, use integers
PHP Code:

new iArgs];
iArgs] = attacker;
iArgs] = client;
//Again, why are you using set_task()?
set_task(0.1"Timer_RoundEndCondition"1024iArgs sizeofiArgs) ) 


Vit_amin 01-23-2016 20:19

Re: read_data doesn't return value
 
Guys help me Please, i don't know what is it ...
Why Client Index different's

Vit_amin 01-23-2016 20:22

Re: read_data doesn't return value
 
I have this piece of code a long time not touched, but I think I've had problems there that did not end the round


All times are GMT -4. The time now is 09:29.

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