AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   what is wrong with my code ? (https://forums.alliedmods.net/showthread.php?t=327529)

Mankled 09-24-2020 23:06

what is wrong with my code ?
 
What's happening is when I tested it on my server, I get log errors on logs folder from my server (it says to enable debug mode). but when I compile. it compiles without errors.

PHP Code:

on top:
new 
getmoney[33]


mid of the command:
if (
getmoney[id] >= 2)
    {
        
client_print(idprint_chat"You cant use it now.")
        return;
    }
// if he didnt get his money more than 2 times
getmoney[id]++ 


Supremache 09-24-2020 23:24

Re: what is wrong with my code ?
 
What you are trying to do ?? or show me all plugin !!

fysiks 09-24-2020 23:37

Re: what is wrong with my code ?
 
It said to enable debug so you should enable debug. When you get the full error with debug enabled, you'll get a much better idea of what is actually wrong. If you still can't figure it out, post that entire output here with the entire plugin.

Black Rose 09-25-2020 14:52

Re: what is wrong with my code ?
 
Quote:

Originally Posted by Mankled (Post 2718756)
What's happening

EXACTLY what we're asking here. You tell us.

Mankled 09-26-2020 00:12

Re: what is wrong with my code ?
 
1 Attachment(s)
I enabled debug mode and I found the problem, but i dont know how to solve it:

I use ZPA mode and im getting the error on line 2518:

PHP Code:

if (g_nemesis[victim] || g_assassin[victim] || (g_assassin[attacker] && get_pcvar_num(cvar_nemfraggore))) 

Error:
PHP Code:

L 09/25/2020 14:10:34: [AMXX]    [0zombie_plague_advance_v1-6-1.sma::fw_PlayerKilled (line 2518)
L 09/25/2020 14:10:34: [AMXXDisplaying debug trace (plugin "zombie_plague_advance_v1-6-1.amxx")
L 09/25/2020 14:10:34: [AMXXRun time error 4index out of bounds 

Here is the .sma

Black Rose 09-26-2020 05:29

Re: what is wrong with my code ?
 
Code:
if (g_nemesis[victim] || g_assassin[victim] || ( is_user_connected(attacker) && g_assassin[attacker] && get_pcvar_num(cvar_nemfraggore)))

fysiks 09-26-2020 23:55

Re: what is wrong with my code ?
 
Quote:

Originally Posted by Black Rose (Post 2719027)
Code:
if (g_nemesis[victim] || g_assassin[victim] || ( is_user_alive(attacker) && g_assassin[attacker] && get_pcvar_num(cvar_nemfraggore)))

If this is the fix, you should explain what you actually did so people can understand without having to intimately inspect the code that you posted and assume that what you posted is the fix. The Scripting Help forum is for learning after all.

Checking if the attacker is alive is not the proper solution to this problem. Whether or not a player is dead or alive is not a cause of an index out-of-bounds error. Also, the attacker might not be alive but the action should likely still happen. I believe that the proper solution is to check if the attacker is an actual player i.e. 0 < attacker < maxplayers

Black Rose 09-27-2020 08:08

Re: what is wrong with my code ?
 
Quote:

Originally Posted by fysiks (Post 2719166)
If this is the fix, you should explain what you actually did so people can understand without having to intimately inspect the code that you posted and assume that what you posted is the fix. The Scripting Help forum is for learning after all.

Checking if the attacker is alive is not the proper solution to this problem. Whether or not a player is dead or alive is not a cause of an index out-of-bounds error. Also, the attacker might not be alive but the action should likely still happen. I believe that the proper solution is to check if the attacker is an actual player i.e. 0 < attacker < maxplayers

Actually posting code > bitching about posts in the wrong forum, non-descriptive titles, et.c.

This is a forum. It's somewhat of a dialogue. If the user responds with "I don't understand, can you explain" I would. The change is so small that comparing it is so easy there's no point of explaining. The thread author also doesn't seem to have any knowledge of coding and also no interest in changing that.

fysiks 09-27-2020 14:40

Re: what is wrong with my code ?
 
Quote:

Originally Posted by Black Rose (Post 2719218)
This is a forum. It's somewhat of a dialogue. If the user responds with "I don't understand, can you explain" I would. The change is so small that comparing it is so easy there's no point of explaining. The thread author also doesn't seem to have any knowledge of coding and also no interest in changing that.

It's just a waste of time to not explain it, it would take like 20 seconds to do in your original post. Just because you believe that the poster doesn't have knowledge of coding doesn't mean you can't explain it so that he or she can learn. Also, people may come in the future and be curious why you made such a change.

Natsheh 09-28-2020 09:30

Re: what is wrong with my code ?
 
Such a problem have atons of solutions meaning that if the User searched for a solution he will definitely find one, instead of making a useless thread.


All times are GMT -4. The time now is 12:21.

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