15.01.2012, 22:08
Hello, I would like some help making a, score system with timers and a saving position system after logged out.
I am using y_ini.
I am using y_ini.
new Float:X, Float:Y, Float:Z;
GetPlayerPos(playerid, X, Y, Z);
INI_WriteFloat(File, "X", X);
INI_WriteFloat(File, "Y", Y);
INI_WriteFloat(File, "Z", Z);
new myTime[MAX_PLAYERS];
public OnPlayerSpawn(playerid)
{
myTime[playerid] = SetTimer("RegMoney", 60000, false); //This creates a timer that is 60,000 milliseconds (60 seconds) in length, and it doesn't repeat. After 60 seconds it calls our RegMoney function
}
forward RegMoney();
public RegMoney()
{
new file[64]; //we create our string so we can format it with the players account file
format(file, sizeof(file), "MyFiles/Accounts/%s.ini", Name(playerid)); //we format our file string to their account path
if(!dini_Exists(file)) return SendClientMessage(playerid, 0xCC0000AA, "If you register, you recieve some cash!"); //Lets send them this if they aren't registered
if(dini_Exists(file)) //we check if it exists
{
if(dini_Int(file, "RegMoney") == 0) //We check if they haven't already gotten their money (0 = they haven't, 1 = they have)
{
dini_SetInt(file, "RegMoney", 1); //If they don't have it set to 1, we set it to 1
GivePlayerMoney(playerid, PocketMoney); //then we give them some money
format(file, sizeof(file), "You've recieved $%d for registering!", PocketMoney); //we format our file string to something else
SendClientMessage(playerid, 0x00CCCCAA, file); //we send the formatted message to the player
}
//We wont tell them anything if they've already got it, no need to spam them every time they spawn saying they already recieved it
}
KillTimer(myTime[playerid]); //We kill our timer
}