SA-MP Forums Archive
Question - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Question (/showthread.php?tid=393248)



Question - JustinAn - 17.11.2012

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;
}



Re: Question - Ballu Miaa - 17.11.2012

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;
}



Re: Question - JustinAn - 17.11.2012

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.


Re: Question - Ballu Miaa - 17.11.2012

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.


Re: Question - JustinAn - 17.11.2012

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