[Tutorial] [TUT]Basic Object Streamer
#15

Ok, I dont know if i did i wright, but here are the results:
Code:
pawn Код:
#include <a_samp>
#include <foreach>
forward OneSecTimer();
#define ForEachPlayer(%0) for(new index_%0=0, %0=ConnectedPlayerList[0]; index_%0<ConnectedPlayers; index_%0++, %0=ConnectedPlayerList[index_%0])
new item1[MAX_PLAYERS][10000],item2[MAX_PLAYERS][10000];
new ConnectedPlayers;
new ConnectedPlayerList[MAX_PLAYERS+1];//Loop would bug when server is full D:
main()
{
    print("\n----------------------------------");
    print("  This is a blank GameModeScript");
    print("----------------------------------\n");
   
    //printf("GetVehicleComponentType %u",GetVehicleComponentType(1100));
   
}

public OnGameModeInit()
{
    // Set timer of 1 second.
    for(new i;i<100;i++)
    {
        Itter_Add(Player, i);
        ConnectedPlayerList[ConnectedPlayers++]=i;
    }
   
    SetTimer("OneSecTimer", 1000, 1);
    print("GameModeInit()");
    SetGameModeText("Timer Test");
    AddPlayerClass(0, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);
    return 1;
}

public OneSecTimer() {
    new sText[256];
    format(sText,sizeof(sText),"GetTickCount = %d",GetTickCount());
    print(sText);
    SendClientMessageToAll(0xFF0000, sText);
   
   
    new time = GetTickCount();
    for (new i = 0; i < 10000; i++)
    {
        foreach(Player,I)
        {
            item1[I][i]=100;
        }
    }
    printf("Time #1: %d", GetTickCount() - time);

    time = GetTickCount();
    for (new i = 0; i < 10000; i++)
    {
        ForEachPlayer(I)
        {
            item2[I][i]=200;
        }
    }
    printf("Time #2: %d", GetTickCount() - time);
}


EDIT: New test:
pawn Код:
#include <a_samp>
#include <foreach>
forward OneSecTimer();
#define ForEachPlayer(%0) for(new index_%0=0, %0=ConnectedPlayerList[0]; index_%0<ConnectedPlayers; index_%0++, %0=ConnectedPlayerList[index_%0])
new item1[MAX_PLAYERS][10000],item2[MAX_PLAYERS][10000],item3[MAX_PLAYERS][10000];
new ConnectedPlayers;
new ConnectedPlayerList[MAX_PLAYERS+1];//Loop would bug when server is full D:
main()
{
    print("\n----------------------------------");
    print("  This is a blank GameModeScript");
    print("----------------------------------\n");
   
    //printf("GetVehicleComponentType %u",GetVehicleComponentType(1100));
   
}

public OnGameModeInit()
{
    // Set timer of 1 second.
    for(new i;i<100;i++)
    {
        Itter_Add(Player, i);
        ConnectedPlayerList[ConnectedPlayers++]=i;
    }
    Itter_Remove(Player,random(50));
    Itter_Remove(Player,random(100));
    for(new i=0;i<100;i++)
    {
        if(ConnectedPlayerList[i]==5)
        {
            ConnectedPlayers--;
            ConnectedPlayerList[i]=ConnectedPlayerList[ConnectedPlayers];
        }
    }
   
    SetTimer("OneSecTimer", 1000, 1);
    print("GameModeInit()");
    SetGameModeText("Timer Test");
    AddPlayerClass(0, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);
    return 1;
}

public OneSecTimer() {
    new sText[256];
    format(sText,sizeof(sText),"GetTickCount = %d",GetTickCount());
    print(sText);
   
   
    new time = GetTickCount();
    for (new i = 0; i < 10000; i++)
    {
        foreach(Player,I)
        {
            item1[I][i]=100;
        }
    }
    printf("Time #1: %d", GetTickCount() - time);

    time = GetTickCount();
    for (new i = 0; i < 10000; i++)
    {
        ForEachPlayer(I)
        {
            item2[I][i]=200;
        }
    }
    printf("Time #2: %d", GetTickCount() - time);

    time = GetTickCount();
    for (new i = 0; i < 10000; i++)
    {
        for(new I;I<100;I++)
        {
            if(I != 40)
            {
                item3[I][i]=300;
            }
        }
    }
    printf("Time #3: %d", GetTickCount() - time);
}
Reply


Messages In This Thread
[TUT]Basic Object Streamer - by [HiC]TheKiller - 03.01.2010, 11:02
Re: [TUT]Basic Object Streamer - by [03]Garsino - 03.01.2010, 12:45
Re: [TUT]Basic Object Streamer - by [HiC]TheKiller - 03.01.2010, 22:36
Re: [TUT]Basic Object Streamer - by [HiC]TheKiller - 04.01.2010, 01:53
Re: [TUT]Basic Object Streamer - by Wasim_Cortez - 04.01.2010, 12:47
Re: [TUT]Basic Object Streamer - by V1ceC1ty - 04.01.2010, 14:31
Re: [TUT]Basic Object Streamer - by [HiC]TheKiller - 04.01.2010, 18:26
Re: [TUT]Basic Object Streamer - by adytzu32 - 06.03.2010, 11:59
Re: [TUT]Basic Object Streamer - by adytzu32 - 06.03.2010, 18:01
Re: [TUT]Basic Object Streamer - by wups - 25.08.2010, 13:32
Re: [TUT]Basic Object Streamer - by almighty - 25.08.2010, 15:36
Re: [TUT]Basic Object Streamer - by wups - 25.08.2010, 19:14
Re: [TUT]Basic Object Streamer - by wups - 25.08.2010, 19:38
Re: [TUT]Basic Object Streamer - by [HiC]TheKiller - 25.08.2010, 19:53
Re: [TUT]Basic Object Streamer - by wups - 25.08.2010, 19:53
Re: [TUT]Basic Object Streamer - by almighty - 25.08.2010, 21:55
Re: [TUT]Basic Object Streamer - by Jay_ - 25.08.2010, 22:29
Respuesta: [TUT]Basic Object Streamer - by ipsBruno - 25.08.2010, 22:49
Re: [TUT]Basic Object Streamer - by wups - 26.08.2010, 10:45
Re: [TUT]Basic Object Streamer - by Las Venturas CNR - 24.10.2010, 15:50
Re: [TUT]Basic Object Streamer - by [FSaF]Jarno - 07.07.2011, 18:20
Re: [TUT]Basic Object Streamer - by [HiC]TheKiller - 07.07.2011, 20:25
Re: [TUT]Basic Object Streamer - by §с†¶e®РµРe - 12.01.2012, 13:08
Re: [TUT]Basic Object Streamer - by Guitar - 19.02.2012, 13:25

Forum Jump:


Users browsing this thread: 1 Guest(s)