Raised This Month: $51 Target: $400
 12% 

Help me to fix all the error


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
tiger750
New Member
Join Date: Mar 2024
Old 03-04-2024 , 09:42   Help me to fix all the error
Reply With Quote #1

Hi, i need help to fix all the error i have amxx file but i dont have sma file i will make decompile amxx to sma and here is the output resault but it have lot of error can anyone help me for fix the all error and make fresh compile sma file.

new MaxClients;
new String:NULL_STRING[4];
new Float:NULL_VECTOR[3];
replace_all(string[], len, what[], with[])
{
new pos;
if ((pos = contain(string, what)) == -1)
{
return 0;
}
new total;
new with_len = strlen(with);
new diff = strlen(what) - with_len;
new total_len = strlen(string);
new temp_pos;
while (replace(string[pos], len - pos, what, with))
{
total++;
pos = with_len + pos;
total_len -= diff;
if (!(pos >= total_len))
{
temp_pos = contain(string[pos], what);
if (!(temp_pos == -1))
{
pos = temp_pos + pos;
}
return total;
}
return total;
}
return total;
}

public plugin_init()
{
register_plugin("welcome & dead hud", "1.0", "Farhan Shaikh");
register_clcmd("say /offhud", "cmdHudOff", -1, 256, -1, MaxClients);
register_clcmd("say /onhud", "cmdHudOn", -1, 256, -1, MaxClients);
return 0;
}

public client_putinserver(id)
{
set_task(1084227584, "show_dead_hud", id, 404, MaxClients, 396, MaxClients);
set_task(1084227584, "welcomemsg", id, 404, MaxClients, 452, MaxClients);
return 0;
}

public show_dead_hud(id)
{
if (!is_user_connected(id))
{
return 0;
}
new var1;
if (is_user_connected(id) && !is_user_alive(id))
{
set_hudmessage(MaxClients, 255, 252, 1008981770, 1045220557, MaxClients, 1086324736, 1084227584, 1036831949, 1045220557, -1);
show_hudmessage(id, "~~~~~~~~~~~~~~~~~~~ \n Save all our IP's, If the Main IP is \n not visible then kindly try joining from other IP \n * 152.67.27.93:27015 \n * 144.24.100.130:27015 \n * 140.238.167.130:27015\n Type /offhud To Remove This Message \n~~~~~~~~~~~~~~~~~~~");
}
return 0;
}

public cmdHudOff(id)
{
remove_task(id, MaxClients);
ColorChat(id, "!gYour turned !tOFF !ghud");
return 0;
}

public cmdHudOn(id)
{
show_dead_hud(id);
set_task(1065353216, "show_dead_hud", id, 404, MaxClients, 1588, MaxClients);
ColorChat(id, "!gYou turned !tON !ghud");
return 0;
}

public welcomemsg(id)
{
set_hudmessage(MaxClients, 255, 42, -1082130432, 1050253722, MaxClients, 1086324736, 1084227584, 1036831949, 1045220557, -1);
show_hudmessage(id, "~~~~~~~~~~~~~~~~~~~ \n Save all our IP's, If the Main IP is \n not visible then kindly try joining from other IP \n * 152.67.27.93:27015 \n * 144.24.100.130:27015 \n * 140.238.167.130:27015\n ~~~~~~~~~~~~~~~~~~~");
ColorChat(id, "!t==>> !gSave all our IP's, If the Main IP is not visible then kindly try joining from other IP");
ColorChat(id, "!t==>> !y*!g152.67.27.93:27015 !y*!g144.24.100.130:27015 !y*!g140.238.167.130:27015");
return 0;
}

ColorChat(id, input[])
{
new count = 1;
new players[32];
static msg[191];
vformat(msg, 190, input, 3);
replace_all(msg, 190, "!y", 4012);
replace_all(msg, 190, "!g", 4032);
replace_all(msg, 190, "!t", 4052);
if (id)
{
players[0] = id;
}
else
{
get_players(players, count, "ch", 4072);
}
new i;
while (i < count)
{
if (is_user_connected(players[i]))
{
message_begin(NULL_VECTOR, get_user_msgid("SayText"), 4108, players[i]);
write_byte(players[i]);
write_string(msg);
message_end();
}
i++;
}
return 0;
}
tiger750 is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 03-04-2024 , 23:20   Re: Help me to fix all the error
Reply With Quote #2

FYI, if you post any code or code-like text, place it in [code][/code] tags.

What you did post appears to be missing a whole bunch of statically defined strings. These go where when you compile, you get a argument type mismatch and it's an integer when it should be a string.

The MaxClients variable appears to be used in the most random places, not sure how this is possible unless the original author didn't know what they were doing (I'm not an expert with decompiling so maybe there is an explanation; regardless, those would need to be fixed).

For locations where there is an integer but should be a float, you can use this to convert it back to a floating point value:

PHP Code:
#include <amxmodx>

public plugin_init()
{
    
register_srvcmd("convert""cmdConvert")
}

public 
cmdConvert()
{
    new 
szArg[32], iArg
    read_argv
(1szArgcharsmax(szArg))
    
iArg str_to_num(szArg)
    
server_print("%.3f"Float:iArg)

However, generally, it's usually easiest to just re-write the plugin entirely from scratch.
__________________
fysiks is offline
tiger750
New Member
Join Date: Mar 2024
Old 03-07-2024 , 23:24   Re: Help me to fix all the error
Reply With Quote #3

Ahh, thanks for your advice mate

Quote:
Originally Posted by fysiks View Post
FYI, if you post any code or code-like text, place it in [code][/code] tags.

What you did post appears to be missing a whole bunch of statically defined strings. These go where when you compile, you get a argument type mismatch and it's an integer when it should be a string.

The MaxClients variable appears to be used in the most random places, not sure how this is possible unless the original author didn't know what they were doing (I'm not an expert with decompiling so maybe there is an explanation; regardless, those would need to be fixed).

For locations where there is an integer but should be a float, you can use this to convert it back to a floating point value:

PHP Code:
#include <amxmodx>

public plugin_init()
{
    
register_srvcmd("convert""cmdConvert")
}

public 
cmdConvert()
{
    new 
szArg[32], iArg
    read_argv
(1szArgcharsmax(szArg))
    
iArg str_to_num(szArg)
    
server_print("%.3f"Float:iArg)

However, generally, it's usually easiest to just re-write the plugin entirely from scratch.

Last edited by tiger750; 03-07-2024 at 23:26.
tiger750 is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 18:46.


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