[Tutorial] HeadShot System [Explained]
#21

Quote:
Originally Posted by SickAttack
View Post
Too overdone, just use a variable (boolean) and set it to true when the player spawns, and to false when the player dies or leaves the server. Simple as that.
About IsPlayerDead : By considering what you said, it can fail sometimes. OnPlayerSpawn can be bypassed, though it's the responsibility of the server developer. But there are exceptional cases where you get spawned without OnPlayerSpawn getting called, so I'd recommend to consider state too along with what SickAttack suggested.

OT : There's no need to check if both the players have no teams assigned. If one among them doesn't have a team then it's assured that both either has no team or are from different teams.
Other than that, good tutorial.
Reply
#22

You can do the seths command simply like this
PHP Code:
COMMAND:seths(playeridparams[])
    {
        
//replace with your admin system
        
if(IsPlayerAdmin(playerid))
        {
            
HeadShotSystem = !HeadShotSystem;
            new 
string11[109], pname[24];
            
GetPlayerName(playeridpname24);
            
format(string11sizeof(string11), "[Admin] Server admin %s(%d) has %s Headshot system!"pname,playerid,(HeadShotSystem)?("enabled"):("disabled"));
            
SendClientMessageToAll(-1string11);
        }
        return 
1;
    } 
Reply
#23

@Sreyas: Thanks! appreciated i never knew about that thing, have a cookie!

About the rest, i started thinking my original code was better, as one suggestion is conflicting with another and in the end i am coming back to my origianl code o.o
Reply
#24

Quote:
Originally Posted by iLearner
View Post
@Sreyas: Thanks! appreciated i never knew about that thing, have a cookie!

About the rest, i started thinking my original code was better, as one suggestion is conflicting with another and in the end i am coming back to my origianl code o.o
Lordzy gave a good example why using a variable can cause trouble sometimes. So the best way you can go with:
PHP Code:
if (GetPlayerState(playerid) != PLAYER_STATE_WASTED
Reply
#25

Quote:
Originally Posted by saffierr
View Post
How is it considered as 'better' lol, I truly don't see how, as it's different for everyone.
Having "new bool:Something = false;" is just for the sight of your eyes, and yes, I know a boolean is FALSE by default, but as I've said, it's just for the sight.
I do not see how it is possibly considered as better.
Not better, but as better programming practice. Like I said, you aren't going to find any high level projects (or whatever you want to call them) do any of that.

Quote:
Originally Posted by Michael Shimmins
The first example nearly always wins in my book:

if(foo)
{
}
It's shorter and more concise. Why add an extra check to something when it's absolutely not needed? Just wasting cycles...

I do agree, though, that sometimes the more verbose syntax makes things more readable (which is ultimately more important as long as performance is acceptable) in situations where variables are poorly named.
There are tens and thousands of other comments behind the matter just like that one, look it up or continuing doing the opposite. Whatever, I can't force you to do anything, really.

-----

Quote:
Originally Posted by Lordzy
View Post
About IsPlayerDead : By considering what you said, it can fail sometimes. OnPlayerSpawn can be bypassed, though it's the responsibility of the server developer. But there are exceptional cases where you get spawned without OnPlayerSpawn getting called, so I'd recommend to consider state too along with what SickAttack suggested.

OT : There's no need to check if both the players have no teams assigned. If one among them doesn't have a team then it's assured that both either has no team or are from different teams.
Other than that, good tutorial.
Is that so? Please explain how it can be recreated.

Getting desynced is honestly the only way it won't be called, are you referring to that?
Reply
#26

Quote:
Originally Posted by SickAttack
View Post
Is that so? Please explain how it can be recreated.

Getting desynced is honestly the only way it won't be called, are you referring to that?
Getting desynced is one among them. Another reason, I'd say is caused due to latency. I've experienced situations where OPS fails when OPD is called twice in a row, this is a rare case though. Others, like I stated, there are fake spawns and fake kills that can bypass, but it's always up to the developer to have safeguard. PLAYER_STATE_WASTED would be pretty much fine to check.
Reply
#27

Edited stuff suggested above.
Reply
#28

Well the tutorial is OK, but you could also explain the command not just tell people to copy and paste it into their script.
Reply
#29

Quote:
Originally Posted by Lordzy
View Post
Getting desynced is one among them. Another reason, I'd say is caused due to latency. I've experienced situations where OPS fails when OPD is called twice in a row, this is a rare case though. Others, like I stated, there are fake spawns and fake kills that can bypass, but it's always up to the developer to have safeguard. PLAYER_STATE_WASTED would be pretty much fine to check.
I'm pretty much calling bullshit on this.

After playing SA-MP for a long time, and running a server that specifically uses a variable, OPS was always called except when a player gets desynced (which is even better since that will prevent players from performing certain actions as the server doesn't mark them as spawned, they can't be killed, etc., etc.).
Reply
#30

Quote:
Originally Posted by GoldenLion
View Post
Well the tutorial is OK, but you could also explain the command not just tell people to copy and paste it into their script.


The orange text is explanation, just so that you know.
Reply
#31

Quote:
Originally Posted by iLearner
View Post


The orange text is explanation, just so that you know.
Quote:
Originally Posted by GoldenLion
View Post
Well the tutorial is OK, but you could also explainthe command not just tell people to copy and paste it into their script.
I know there's not too much to explain, but what if people don't know what is that command thing or something? You didn't mention a command processor. Some newbies could come here and have no idea at all what is it.

EDIT: wait wtf lol
Quote:
Originally Posted by iLearner
View Post
- sscanf (for the cmd we've used)
Reply
#32

I've been reading both of your stories (Sickattack, Lordzy),
And I'm not convinced by another, on which IF check to use lol...
PHP Code:
if (GetPlayetState(playerid) != PLAYER_STATE_WASTED
Or
PHP Code:
if(!IsPlayerDeath
with the appropriate function...

In my eyes, the first check is more than enough.
Reply
#33

I might agree on some points with lordzy, but not on the check related to Teams, you need to focus a bit on it & you'll understand it.
Reply
#34

Quote:
Originally Posted by GoldenLion
View Post
I know there's not too much to explain, but what if people don't know what is that command thing or something? You didn't mention a command processor. Some newbies could come here and have no idea at all what is it.

EDIT: wait wtf lol
^^^ Why the hell you ignored it? Correct the mistake you did.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)