Little coding questions - For general minor queries 5

Quote:
Originally Posted by ISmokezU
Посмотреть сообщение
Is it possible to check for a function? for example hooking SetPlayerHealth to SetPlayerHealthEx,and check whether "SetPlayerHealth" gets call then ban the individual,is that possible?
SetPlayerHealth isn't called by cheats if you were wondering btw.
Reply

Quote:
Originally Posted by SickAttack
Посмотреть сообщение
SetPlayerHealth isn't called by cheats if you were wondering btw.
Oh no it was an example,but is it possible? what i was asking. ^^
Reply

Quote:
Originally Posted by ISmokezU
Посмотреть сообщение
Oh no it was an example,but is it possible? what i was asking. ^^
Please elaborate more on what you want to do. It's obviously possible by hooking SetPlayerHealth and with a variable.
Reply

Код:
#if defined _ALS_GivePlayerWeapon
	#undef GivePlayerWeapon
#else
#define _ALS_GivePlayerWeapon
#endif

#define GivePlayerWeapon GivePlayerWeaponEx
So now could i check for GivePlayerWeapon(...) then do w/e?
Reply

Tell me what you want to do first.
Reply

Functions don't get called by players/clients, thats what callbacks are for, functions are as the name stands, functions for the coder to use.
Reply

Quote:
Originally Posted by PrO.GameR
Посмотреть сообщение
Functions don't get called by players/clients, thats what callbacks are for, functions are as the name stands, functions for the coder to use.
It's possible to detect whether either is used, but I'm just not sure what he's trying to do.
Reply

Quote:
Originally Posted by SickAttack
Посмотреть сообщение
It's possible to detect whether either is used, but I'm just not sure what he's trying to do.
Then tell me and isn't it obvious? to detect them.
Reply

Anyone has a clue why my inputtext isn't working properly? It occassionally adds/switches random characters.
EDIT: I should note that I use y_inline for all of my dialogs and they all work properly, except for this one.

PHP код:
    if ( playertextid == creation_nameSel playerid ] ) {
         
inline creation_NameSel(piddialogidresponselistitemstring:inputtext[]) {
            
#pragma unused pid, dialogid, listitem
            
if ( ! response ) {
                
// No choice
            
}
            if ( 
response ) {
                if ( ! 
IsRPName inputtext )) {
                    return 
Dialog_ShowCallback playeridusing inline creation_NameSelDIALOG_STYLE_INPUT"Character: Name Selection""Enter your character's name.\n\n\
                        Your name isn't a valid roleplaying name!\nIt has to be in a Firstname_Lastname format.\nIt can't be smaller than 5, or longer than 24 characters."
"Continue""Cancel" );
                }
                new 
nameString 64 ] ; 
                
player_nameSelect playerid ] [ ] = EOS ;
                
strcat(nameStringinputtextMAX_PLAYER_NAME ) ;
                
strcat player_nameSelect playerid ], inputtextMAX_PLAYER_NAME ) ;
                if ( 
strlen inputtext ) > 10 ) {
                    
strdel(nameString10sizeof nameString ) ) ;
                    
strins(nameString"..."10sizeof nameString ) ) ;
                }
                
format nameStringsizeof nameString ), "Name~w~ %s"nameString ) ; 
                
PlayerTextDrawSetString(playeridcreation_nameSel playerid ], nameString ) ;
            }
        }
        
        return 
Dialog_ShowCallback playeridusing inline creation_NameSelDIALOG_STYLE_INPUT"Character: Name Selection""Enter your character's name.""Continue""Cancel" );
    } 
Debug output:

Robert_Sheldon:
Код:
[14:56:17] [Inputtext]: Roaert_Sheldon | [NameStr]: Roaert_Sheldon | [NameSelect]: Roaert_Sheldon
Billy_Joe:
Код:
[14:56:17] [Inputtext]: Bihly_Joe | [NameStr]: Bihly_Joe| [NameSelect]: Bihly_Joe
Reply

Quote:
Originally Posted by ISmokezU
Посмотреть сообщение
Then tell me and isn't it obvious? to detect them.
I already told you in a previous reply. The fact you don't want to tell me what you are trying to do is stupid, so that's the only answer I'm giving you.

Quote:
Originally Posted by Dignity
Посмотреть сообщение
Anyone has a clue why my inputtext isn't working properly? It occassionally adds/switches random characters.
EDIT: I should note that I use y_inline for all of my dialogs and they all work properly, except for this one.

PHP код:
    if ( playertextid == creation_nameSel playerid ] ) {
         
inline creation_NameSel(piddialogidresponselistitemstring:inputtext[]) {
            
#pragma unused pid, dialogid, listitem
            
if ( ! response ) {
                
// No choice
            
}
            if ( 
response ) {
                if ( ! 
IsRPName inputtext )) {
                    return 
Dialog_ShowCallback playeridusing inline creation_NameSelDIALOG_STYLE_INPUT"Character: Name Selection""Enter your character's name.\n\n\
                        Your name isn't a valid roleplaying name!\nIt has to be in a Firstname_Lastname format.\nIt can't be smaller than 5, or longer than 24 characters."
"Continue""Cancel" );
                }
                new 
nameString 64 ] ; 
                
player_nameSelect playerid ] [ ] = EOS ;
                
strcat(nameStringinputtextMAX_PLAYER_NAME ) ;
                
strcat player_nameSelect playerid ], inputtextMAX_PLAYER_NAME ) ;
                if ( 
strlen inputtext ) > 10 ) {
                    
strdel(nameString10sizeof nameString ) ) ;
                    
strins(nameString"..."10sizeof nameString ) ) ;
                }
                
format nameStringsizeof nameString ), "Name~w~ %s"nameString ) ; 
                
PlayerTextDrawSetString(playeridcreation_nameSel playerid ], nameString ) ;
            }
        }
        
        return 
Dialog_ShowCallback playeridusing inline creation_NameSelDIALOG_STYLE_INPUT"Character: Name Selection""Enter your character's name.""Continue""Cancel" );
    } 
Debug output:

Robert_Sheldon:
Код:
[14:56:17] [Inputtext]: Roaert_Sheldon | [NameStr]: Roaert_Sheldon | [NameSelect]: Roaert_Sheldon
Billy_Joe:
Код:
[14:56:17] [Inputtext]: Bihly_Joe | [NameStr]: Bihly_Joe| [NameSelect]: Bihly_Joe
Do more debugging (removing parts until it's normal then abnormal / printing after each instance).
Reply

Quote:
Originally Posted by SickAttack
Посмотреть сообщение
Do more debugging (removing parts until it's normal then abnormal / printing after each instance).
There was no need for more debugging because I knew that inputtext caused it, and the debugs were done right after the inline function.

Either way, I suspect my hooks fucked it up or something because I put it in an individual function and it works perfectly now.
Reply

Quote:
Originally Posted by Dignity
Посмотреть сообщение
Anyone has a clue why my inputtext isn't working properly? It occassionally adds/switches random characters.
EDIT: I should note that I use y_inline for all of my dialogs and they all work properly, except for this one.

PHP код:
    if ( playertextid == creation_nameSel playerid ] ) {
         
inline creation_NameSel(piddialogidresponselistitemstring:inputtext[]) {
            
#pragma unused pid, dialogid, listitem
            
if ( ! response ) {
                
// No choice
            
}
            if ( 
response ) {
                if ( ! 
IsRPName inputtext )) {
                    return 
Dialog_ShowCallback playeridusing inline creation_NameSelDIALOG_STYLE_INPUT"Character: Name Selection""Enter your character's name.\n\n\
                        Your name isn't a valid roleplaying name!\nIt has to be in a Firstname_Lastname format.\nIt can't be smaller than 5, or longer than 24 characters."
"Continue""Cancel" );
                }
                new 
nameString 64 ] ; 
                
player_nameSelect playerid ] [ ] = EOS ;
                
strcat(nameStringinputtextMAX_PLAYER_NAME ) ;
                
strcat player_nameSelect playerid ], inputtextMAX_PLAYER_NAME ) ;
                if ( 
strlen inputtext ) > 10 ) {
                    
strdel(nameString10sizeof nameString ) ) ;
                    
strins(nameString"..."10sizeof nameString ) ) ;
                }
                
format nameStringsizeof nameString ), "Name~w~ %s"nameString ) ; 
                
PlayerTextDrawSetString(playeridcreation_nameSel playerid ], nameString ) ;
            }
        }
        
        return 
Dialog_ShowCallback playeridusing inline creation_NameSelDIALOG_STYLE_INPUT"Character: Name Selection""Enter your character's name.""Continue""Cancel" );
    } 
Debug output:

Robert_Sheldon:
Код:
[14:56:17] [Inputtext]: Roaert_Sheldon | [NameStr]: Roaert_Sheldon | [NameSelect]: Roaert_Sheldon
Billy_Joe:
Код:
[14:56:17] [Inputtext]: Bihly_Joe | [NameStr]: Bihly_Joe| [NameSelect]: Bihly_Joe
You should remember that passing an string to a function passes it as a reference, hence any changes made in the function will be applied to the original string parameter.

This can be because of IsRPName function, or any other function used thru OnDialogResponse hooks.
Reply

Quote:
Originally Posted by PrO.GameR
Посмотреть сообщение
This can be because of IsRPName function, or any other function used thru OnDialogResponse hooks.
Yeah that was my first thought. I made several debugs but it was actually the inputtext messing up. Read the reply I made to Sickattack for more info
Reply

Hey does it matter if you use a strong tag or a weak tag with enums?
Код:
enum 
E_Test//Strong tag
{
 E_Sum = 5
};

enum 
e_test//Weak tag
{
e_sum = 1
};
Then again why do people use _: with enums?
Reply

Quote:
Originally Posted by ISmokezU
Посмотреть сообщение
Hey does it matter if you use a strong tag or a weak tag with enums?
Код:
enum 
E_Test//Strong tag
{
 E_Sum = 5
};

enum 
e_test//Weak tag
{
e_sum = 1
};
Then again why do people use _: with enums?
That means nothing, you could go all capslock too. It's just the name.

_: is to detag something (remove tag)
Reply

Quote:
Originally Posted by SickAttack
Посмотреть сообщение
That means nothing, you could go all capslock too. It's just the name.

_: is to detag something (remove tag)
Ok,thanks what do you mean by detag something though?
Reply

Can somebody explain me...
Quote:

[16:28:06] [debug] Run time error 6: "Invalid instruction"
[16:28:06] [debug] Unknown opcode 0x2c at address 0x000E11F0
[16:28:06] [debug] AMX backtrace:
[16:28:06] [debug] #0 native Kick () from samp-server.exe
[16:28:06] [debug] #1 00000004 in ?? (0) from CLASSIFIED.amx
[16:28:06] [debug] #2 0005c194 in public SSCANF_OnPlayerDisconnect (0, 2) from CLASSIFIED.amx
[16:28:06] [debug] #3 00003b24 in public KickTimer (0, 2) from CLASSIFIED.amx

KickTimer function
Код:
forward KickTimer(playerid);
public KickTimer(playerid)
{
	if(playerid != INVALID_PLAYER_ID) Kick(playerid);
	return 1;
}
Reply

Quote:
Originally Posted by SickAttack
Посмотреть сообщение
That means nothing, you could go all capslock too. It's just the name.

_: is to detag something (remove tag)
Do not give random info if you have no idea about the question asked

https://sampforum.blast.hk/showthread.php?tid=318307

Yes, they do have a difference:
Quote:

Strong & Weak tags:

pawn Код:
enum
    E_STRONG //< Since the name starts with a capital letter, the tag is considered "Strong"
{
    E_VAR = 64
};

main()
{
   
    new Test = E_STRONG:E_VAR;
    //Will give you a warning: "tag mismatch" because "Test" doesn't have E_STRONG tag
   
    #pragma unused Test
}
pawn Код:
enum
    e_WEAK //< And here it starts with small letter, so the enum creates a weak tag.
{
    E_VAR = 64
};

main()
{
   
    new Test = e_WEAK:E_VAR;
    //No warning...
   
    #pragma unused Test
}
Quote:
Originally Posted by ALiScripter
Посмотреть сообщение
Can somebody explain me...

KickTimer function
Код:
forward KickTimer(playerid);
public KickTimer(playerid)
{
	if(playerid != INVALID_PLAYER_ID) Kick(playerid);
	return 1;
}
Idk if that seems to be the origin but by the looks of it you are passing yet another parameter to KickTimer, you should fix that.
Quote:

public KickTimer (0, 2)

You should consider re-compiling your code with debug lvl 3 (-d3) when testing your code.
Also I assume this is a linux server? if yes there's a tutorial on how to get more meaningful crash reports.
Reply

Woops, double post -_-
Reply

Quote:
Originally Posted by PrO.GameR
Посмотреть сообщение
Idk if that seems to be the origin but by the looks of it you are passing yet another parameter to KickTimer, you should fix that.

You should consider re-compiling your code with debug lvl 3 (-d3) when testing your code.
Also I assume this is a linux server? if yes there's a tutorial on how to get more meaningful crash reports.
Nope, checked the whole script, I'm not passing any other parameter.
-d3 doesn't works, it doesn't show shit on my compiler output except for some warnings. I replaced my compiler and everything when 0.3.7 got released and downloaded all the new includes and stuff. Linux and Windows server output the exact same errors.
Reply


Forum Jump:


Users browsing this thread: 7 Guest(s)