Question
#1

Hey guys, I'm not sure but in RP servers there's like that kind of things in the public function, OnPlayerConnect. What is that for? Reset the stats of the player? I'm not sure, I'd like an answer.
pawn Код:
public OnPlayerConnect(playerid)
{
    PlayerInfo[playerid][pCash] = 0;
    PlayerInfo[playerid][pAdmin] = 0;
    return 1;
}
Reply
#2

There is no function provided in SA-MP to reset the players statistics. However you can create your own functions or Do it the way your doing it Under OnPlayerConnect , that is correct!

Or Creating your own functions is like:

Creating a stock.
pawn Код:
stock ResetPlayerStats(playerid)
{
    PlayerInfo[playerid][pCash] = 0;
    PlayerInfo[playerid][pAdmin] = 0;
    return 1;
}
Or creating a custom callback.

pawn Код:
forward ResetPlayerStats(playerid)
public ResetPlayerStats(playerid)
{
    PlayerInfo[playerid][pCash] = 0;
    PlayerInfo[playerid][pAdmin] = 0;
    return 1;
}
And then you can use these functions where ever you want to as:
pawn Код:
public OnPlayerConnect(playerid)
{
    ResetPlayerStats(playerid);
    return 1;
}
Reply
#3

Yea, but I see it in RP servers. Why do they even use it for?

EDIT: And, that code. I meant I see it in the scripts.
Reply
#4

Quote:
Originally Posted by JustinAn
Посмотреть сообщение
Yea, but I see it in RP servers. Why do they even use it for?
Depends on what they want to do. They can reset any integer variable or floating variable using these functions whenever they want. Making a function and calling it again & again. Reduces our work to write all that again and again. So we create one function once! and just call it wherever we want it to do the particular task which it is created for.
Reply
#5

Quote:
Originally Posted by Ballu Miaa
Посмотреть сообщение
Depends on what they want to do. They can reset any integer variable or floating variable using these functions whenever they want. Making a function and calling it again & again. Reduces our work to write all that again and again. So we create one function once! and just call it wherever we want it to do the particular task which it is created for.
Oh, alright. Thanks alot , finally found it out. +REP
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)