Is this possible to script ?
#4

Alright. I decided to do it for you, all I ask in return is a thanks and rep

pawn Код:
new aPoints[MAX_PLAYERS] = 0;

public OnPlayerConnect(playerid)
{
    aPoints[MAX_PLAYERS] = 0;
    return 1;
}

public OnPlayerDisconnect(playerid, reason)
{
    //Example for saving: (Save before setting aPoints to 0)
    if(LoggedIn[playerid] == 1) //if they aren't logged in, they dont need to be saved
    {
        new name[30];
        new str[128];
        //MYSQL:
        new query[128];
        GetPlayerName(playerid,name,sizeof(name));
        mysql_real_escape_string(name,name);
        format(query,sizeof(query),"UPDATE Accounts SET aPoints = %d WHERE Username = '%s'",aPoints[playerid],query);
        mysql_query(query);
        //or FLAT FILES:
        GetPlayerName(playerid,name,sizeof(name));
        format(str,sizeof(str),"Accounts/%s.txt",name);
        new File: fSave = fopen(str,io_write);
        format(str,sizeof(str),"aPoints=%d",aPoints(playerid));
        fwrite(fSave,str);
        fclose(fSave);
    }
    aPoints[MAX_PLAYERS] = 0;
    return 1;
}

public OnPlayerDeath(playerid, killerid, reason)
{
    //Maybe put a check for any DM and decrease admin points for bad kills?
    return 1;
}

public OnPlayerStateChange(playerid, newstate, oldstate)
{
    //Stealing a car, bad offense? -1 aPoint
    return 1;
}

ZCMD:givepoint(playerid,params[])
{
    if(IsNotAnAdmin(playerid)) return 0;
    if(isnull(params)) return SendClientMessage(playerid,color_white,"USAGE: /givepoint (playerid)");
    new id = strval(params);
    if(id == playerid || !IsPlayerConnected(id)) return SendClientMessage(playerid,color_red,"Invalid playerid");
    aPoints[id] = aPoints[id] + 1;
    new str[128],name[2][30];
    GetPlayerName(playerid,name[0]);
    GetPlayerName(id,name[1]);
    format(str,sizeof(str),"The administrator '%s' has given you an Administrator Point.",name[0]);
    SendClientMessage(id,color_green,str);
    format(str,sizeof(str),"You have given '%s' an Administrator Point.",name[1]);
    SendClientMessage(playerid,color_green,str);
    return 1;
}
ZCMD:setpoint(playerid,params[])
{
    if(IsNotAnAdmin(playerid)) return 0;
    new id,amount;
    if(sscanf(params,"ii",id,amount)) return SendClientMessage(playerid,color_white,"USAGE: /setpoint (playerid) (point)");
    aPoints[id] = amount;
    if(id == playerid || !IsPlayerConnected(id)) return SendClientMessage(playerid,color_red,"Invalid playerid");
    new str[128],name[2][30];
    GetPlayerName(playerid,name[0]);
    GetPlayerName(id,name[1]);
    format(str,sizeof(str),"The administrator '%s' has set your Administrator Points to %d.",name[0],amount);
    SendClientMessage(id,color_red,str);
    format(str,sizeof(str),"You have set '%s' Administrator Points to %d.",name[1],amount);
    SendClientMessage(playerid,color_red,str);
    return 1;
}
ZCMD:buylevel(playerid,params[])
{
    if(IsNotAnAdmin(playerid)) return 0;
    if(isnull(params)) return SendClientMessage(playerid,color_white,"USAGE: /givepoint (playerid)");
    new level = strval(params);
    if(Admin[playerid] >= level || Admin[playerid] <= level) return SendClientMessage(playerid,color_red,"Invalid level.");
    if(level < 1 || level > 3) return SendClientMessage(playerid,color_red,"Invalid level.");
    if(level == 1 && aPoints[playerid] < 15) return SendClientMessage(playerid,color_red,"Not enough points!");
    if(level == 2 && aPoints[playerid] < 30) return SendClientMessage(playerid,color_red,"Not enough points!");
    if(level == 3 && aPoints[playerid] < 50) return SendClientMessage(playerid,color_red,"Not enough points!");
    switch(level)
    {
        case 1:
        {
            aPoints[playerid] = aPoints[playerid] - 15;
        }
        case 2:
        {
            aPoints[playerid] = aPoints[playerid] - 30;
        }
        case 3:
        {
            aPoints[playerid] = aPoints[playerid] - 50;
        }
    }
    Admin[playerid] = level;
    new str[128];
    format(str,sizeof(str),"You have bought the admin level %d for 30 days, congratulations.",level);
    SendClientMessage(id,color_green,str);
    TempAdmin[playerid] = getdate();+30//check on logins if the date is equal to or over this variable (save it)
    return 1;
}
Reply


Messages In This Thread
Is this possible to script ? - by sniperwars - 09.03.2012, 18:22
Re: Is this possible to script ? - by coole210 - 09.03.2012, 18:56
Re: Is this possible to script ? - by Tanush123 - 09.03.2012, 19:47
Re: Is this possible to script ? - by coole210 - 09.03.2012, 21:01
Re: Is this possible to script ? - by Max_Coldheart - 09.03.2012, 21:05
Re: Is this possible to script ? - by TheDominator - 09.03.2012, 21:10
Re: Is this possible to script ? - by sniperwars - 09.03.2012, 21:38
Re: Is this possible to script ? - by sniperwars - 09.04.2012, 03:45
Re: Is this possible to script ? - by Ezay - 09.04.2012, 03:54
Re: Is this possible to script ? - by Shetch - 09.04.2012, 03:56

Forum Jump:


Users browsing this thread: 1 Guest(s)