[help]OnPlayerUpdate uses
#1

Anyone know what can we do in OnPlayerUpdate ? I give example : I want apply something when a variable changes , so should I do codes under OnPlayerUpdate ?
Reply
#2

I'd recommend making a function that you'll call when changing the variable, and inside that function do whatever you want to do.

Example:

pawn Код:
MyVariableChangeFunction(newvalue)
{
    MyVariable = newvalue;
   
    // my stuff
}

// Somewhere when I'm changing the variable:

MyVariableChangeFunction( HERETHEVALUEYOUWANTITTOCHANGETO );
Reply
#3

If a variable changes, you KNOW when it changes (because YOU changed it with an operation) so why would you want to check thousands of times a second if it was changed? Just call a function to set the variable, and in that function do whatever.

EDIT: @LarzI beat me by a max of 15 seconds :/
Reply
#4

It depends on what you want to do. If you need to call something for a player roughly 25 times per second (which stacks, so 10 players = 25*10 calls per second) then you would use OnPlayerUpdate.
Reply
#5

thank you , I really wanna do like killingstreak system
pawn Код:
if(kill=x)
{
//made a triple kill!
}
else if(...)
.
.
Reply
#6

That's what OnPlayerDeath is for.
Reply
#7

ok ,but on question : Is adding conditions in OnPlayerDeath will abord the server readin other codes ?
pawn Код:
Public onplayerdeath
{
//I will here add killing streak with condiitions

//and here are +score &  others thing that are called on player death
}
so will it read the conditions only & stop or contunues?
}
Reply
#8

The code will only stop if you return a value or if you use goto(confirm this, please, as I am not entirely sure). If you don't do either, the code will run until it reaches the end of the callback (The last closing brace)
Reply
#9

thank you ! so it will contunue (cause I have no returns or 'contunue'.. only conditions)
Reply


Forum Jump:


Users browsing this thread: 4 Guest(s)