Level system, reserved vehicles, ...
#1

Hello, im actually creating my own gamemod (started at 0) but i really dont know how to create certain system like:
-a payday which gives a certain amount of money every hours (that amount could be changed if the player is in a faction, or smthing else... with an experience point system assiocated: every hour, the player gain one experience point, and also a level system with that experience points (like every RP servers)
-how to make vehicles accessible only for a faction/group

Sorry for my bad english, im french...
By the way, if you can use as many simple words as you can, it would really help me!
Thank you,
Tetsu
Reply
#2

This

Код:
// Top of script

new CurrentSession[ MAX_PLAYERS ] // Create an array which keeps track of how many seconds the player has been on the server.
;

forward PayDay( ); // Forwarding the payday function.
forward ThreeSecondTimer( ); // Forwarding the session increment function.

// OnGameModeInit

SetTimer( "PayDay", 1800000, true ); // Setting the payday timer for 30 minutes.
SetTimer( "ThreeSecondTimer", 3000, true ); // Setting the session timer for 3 seconds.

// OnPlayerConnect

CurrentSession[ playerid ] = 0; // When a new player connects, their session time should be 0.

// Outside callbacks

public ThreeSecondTimer( )
{
    for( new i; i < MAX_PLAYERS; i++ ) // Can be substituted with foreach (Recommended)
    {
        if( IsPlayerConnected( i ) ) // If the player is connected
        {
            CurrentSession[ i ] += 3; // Add 3 to their seconds connected.
        }
    }
    return 1;
}

public PayDay( )
{
    for( new i; i < MAX_PLAYERS; i++ ) // Can be substituted with foreach (Recommended)
    {
        if( IsPlayerConnected( i ) ) // If the player is connected
        {
            if( CurrentSession[ i ] >= 900 ) // If the player has been connected for at least 15 minutes.
            {
                GivePlayerMoney( i, 5000 ); // Give the player money
            }
            else
            {
                SendClientMessage( i, 0xFFFFFFFF, "Server: You haven't played long enough!" ); // The player has not            been connected for at least 15 minutes.
            }
           
            CurrentSession[ i ] = 0; // Reset the session.
        }
    }
    return 1;
}

or this

Код:
SetTimerEx("payday", time, true, "d", playerid);//time has to be defined
Код:
public payday(playerid)
{
     GameTextForPlayer(playerid, "PAYDAY!!!", 10000, 3);
     SendClientMessage(playerid, YOUR_COLOR_HERE, "YOUR MESSAGE");
     GivePlayerMoney(playerid, 5000);// or whatever you want
     return 1;
}
Reply
#3

Quote:
Originally Posted by Crime Life ROLEPLAY
Посмотреть сообщение
This

Код:
// Top of script

new CurrentSession[ MAX_PLAYERS ] // Create an array which keeps track of how many seconds the player has been on the server.
;

forward PayDay( ); // Forwarding the payday function.
forward ThreeSecondTimer( ); // Forwarding the session increment function.

// OnGameModeInit

SetTimer( "PayDay", 1800000, true ); // Setting the payday timer for 30 minutes.
SetTimer( "ThreeSecondTimer", 3000, true ); // Setting the session timer for 3 seconds.

// OnPlayerConnect

CurrentSession[ playerid ] = 0; // When a new player connects, their session time should be 0.

// Outside callbacks

public ThreeSecondTimer( )
{
    for( new i; i < MAX_PLAYERS; i++ ) // Can be substituted with foreach (Recommended)
    {
        if( IsPlayerConnected( i ) ) // If the player is connected
        {
            CurrentSession[ i ] += 3; // Add 3 to their seconds connected.
        }
    }
    return 1;
}

public PayDay( )
{
    for( new i; i < MAX_PLAYERS; i++ ) // Can be substituted with foreach (Recommended)
    {
        if( IsPlayerConnected( i ) ) // If the player is connected
        {
            if( CurrentSession[ i ] >= 900 ) // If the player has been connected for at least 15 minutes.
            {
                GivePlayerMoney( i, 5000 ); // Give the player money
            }
            else
            {
                SendClientMessage( i, 0xFFFFFFFF, "Server: You haven't played long enough!" ); // The player has not            been connected for at least 15 minutes.
            }
           
            CurrentSession[ i ] = 0; // Reset the session.
        }
    }
    return 1;
}

or this

Код:
SetTimerEx("payday", time, true, "d", playerid);//time has to be defined
Код:
public payday(playerid)
{
     GameTextForPlayer(playerid, "PAYDAY!!!", 10000, 3);
     SendClientMessage(playerid, YOUR_COLOR_HERE, "YOUR MESSAGE");
     GivePlayerMoney(playerid, 5000);// or whatever you want
     return 1;
}
Gee, some of that code looks familiar.
Reply
#4

Well if I had to make a payday system that paid per hour, I would have a constant timer checking the time to make sure it's not just paying per hour, but paying ON the hour.

pawn Код:
forward TimeUpdate();
public OnGameModeInit()
{
    SetTimer("TimeUpdate",60000,1); //every minute
    return 1;
}
public TimeUpdate()
{
    new hh,mm,ss;
    gettime(hh,mm,ss);
    if(mm==0)
    {
        for(new playerid;playerid<MAX_PLAYERS;playerid++)
        {
            if(!IsPlayerConnected(playerid))continue;
            GivePlayerMoney(playerid,5000);
        }
        new string[64];
        format(string,64,"The time is now %d:00, enjoy your payday!",hh);
        SendClientMessageToAll(0xFFFFFFFF,string);
    }
}
EDIT:

For faction only vehicles, you'll have to have a faction system already created, most (if not all) faction systems go by predefined factions with integers as IDs. I personally would much rather use strings to define the factions that way you can create one without having to establish it (just make a code concerning it)

pawn Код:
#define MAX_FACTION_NAME 16
new pFaction[MAX_PLAYERS][MAX_FACTION_NAME];
new pFactionRank[MAX_PLAYERS];
new vFaction[MAX_VEHICLES][MAX_FACTION_NAME];
new vFactionRank[MAX_VEHICLES];

public OnPlayerCommandText(playerid,cmdtext[])
{
    if(!strcmp(cmdtext,"/SetFaction",true,11))
    {
        if(!IsPlayerAdmin(playerid))return 0;
        if(!cmdtext[13])return SendClientMessage(playerid,0xFF0000FF,"USAGE: /SetFaction [playerid] [FullFactionName]");
        new space=strfind(cmdtext," ",true,13);
        if((space==-1)||!cmdtext[space+1])return SendClientMessage(playerid,0xFF0000FF,"USAGE: /SetFaction [playerid] [FullFactionName]");
        space++;
        new player=strval(cmdtext[13]);
        if(!IsPlayerConnected(player))return SendClientMessage(playerid,0xFF0000FF,"Player Not Found");
        pFaction[player]=cmdtext[space];
        new tmp[32];
        format(tmp,32,"Player %d set to faction \"%s\"",player,cmdtext[space]);
        SendClientMessage(playerid,0xFF0000FF,tmp);
        return 1;
    }

    if(!strcmp(cmdtext,"/setvehiclefaction",true,18))
    {
        if(!IsPlayerAdmin(playerid))return 0;
        if(!IsPlayerInAnyVehicle(playerid))return SendClientMessage(playerid,0xFF0000FF,"You are not in a vehicle!");
        if(!cmdtext[20])return SendClientMessage(playerid,0xFF0000FF,"USAGE: /SetVehicleFaction [FullFactionName]");
        vFaction[GetPlayerVehicleID(playerid)]=cmdtext[20];
        new tmp[32];
        format(tmp,32,"Vehicle %d set to faction \"%s\"",GetPlayerVehicleID(playerid),cmdtext[20]);
        SendClientMessage(playerid,0xFF0000FF,tmp);
        return 1;
    }
    return 0;
}

//Lock vehicles that have a faction name against players who don't match factions
public OnVehicleStreamIn(vehicleid,forplayerid)
{
    if(vFaction[vehicleid][0]&&!strcmp(vFaction[vehicleid],pFaction[playerid],true))SetVehicleParamsForPlayer(vehicleid,playerid,0,1);
}
This is kind of a REALLY mini faction script


None of this code has been tested or compiled
Reply
#5

Thank you guys for answering!
I've already made a faction system with IDs.
Silent, even if your faction system looks great, i'd prefer to use my own system with IDs, any ideas i can make vehicles faction with that system?

Is it possible, with these payday scripts, to make amount of money like a variable which i can modify, for example if a player gain money by doing a job, it hads that money plus basic payday?


Moreover, i saw many great houses system, but im looking for the way to create pickups that bring the player to a special interior, like LSPD, hospital...
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)