Jump to content

Question

Posted

am si eu o problema... in aces fs pot vedea doar admini conecatti la rcon check pointurile... cum le pot face sa vada si playeri?

[pawn]#define FILTERSCRIPT

#define MAX_RACE_CPS 300//maximum number of checkpoints

#define MIN_RACE_CPS 5//minimum number of checkpoints

#include <a_samp>

#include <foreach>

new Float:CheckpointCoord[3][MAX_RACE_CPS],

CheckpointsSetted = 0,

cfgRace = 255,

whichCP[MAX_PLAYERS],

placement = 0,

countdowntimer,

saveSecs;

forward StartRaceWithCountdown(playerid, seconds,start);

forward ShowCountdown(playerid,seconds,firstrun);

public OnFilterScriptInit()

{

print("\n--------------------------------------");

print(" tRace simple racesystem by tMike for SA-MP 0.3 loaded.");

print("--------------------------------------\n");

return 1;

}

public OnFilterScriptExit()

{

if(CheckpointsSetted > 0)

{

    foreach(Player,i)

        DisablePlayerRaceCheckpoint(i);

}

KillTimer(countdowntimer);

    cfgRace = 255;

    CheckpointsSetted = 0;

return 1;

}

public OnPlayerConnect(playerid)

{

whichCP[playerid] = 0;

return 1;

}

public StartRaceWithCountdown(playerid, seconds, start)

{

if(seconds == 0)// 0 start it directly

{

SetPlayerRaceCheckpoint(playerid, cfgRace, CheckpointCoord[0][1], CheckpointCoord[1][1], CheckpointCoord[2][1], CheckpointCoord[0][2], CheckpointCoord[1][2], CheckpointCoord[2][2], 14.0);

}

if(start == 0)

{

    saveSecs = seconds;

    new cdstring[4];

    format(cdstring,sizeof(cdstring),"~b~ %d",seconds);

GameTextForPlayer(playerid, cdstring, 5000, 333);

countdowntimer = SetTimerEx("ShowCountdown",1000,1,"d",playerid);

}

return 1;

}

public ShowCountdown(playerid)

{

new cdstring[10];

saveSecs--;

if(saveSecs > 3 && saveSecs < 61)

{

    new randcolor[6];

    PlayerPlaySound(playerid,1056,0.0,0.0,0.0);

    switch(random(6))

    {

case 1: randcolor = "~b~";

case 2: randcolor = "~g~";

case 3: randcolor = "~y~";

case 4: randcolor = "~p~";

case 5: randcolor = "~r~";

case 6: randcolor = "~w~";

    }

format(cdstring,sizeof(cdstring),"%s %d",randcolor,saveSecs);

GameTextForPlayer(playerid, cdstring, 1100, 3);

}

if(saveSecs > 0 && saveSecs < 4)

{

    PlayerPlaySound(playerid,1056,0.0,0.0,0.0);

if(saveSecs == 3)

GameTextForPlayer(playerid, "~p~3", 1100, 3);

else if(saveSecs == 2)

GameTextForPlayer(playerid, "~p~3~n~~y~2", 1100, 3);

else if(saveSecs == 1)

GameTextForPlayer(playerid, "~p~3~n~~y~2~n~~r~1", 1100, 3);

}

else if(saveSecs == 0)

{

whichCP[playerid] = 1;

    PlayerPlaySound(playerid,1057,0.0,0.0,0.0);

    KillTimer(countdowntimer);

GameTextForPlayer(playerid, "~y~Go!~n~~r~Go!~n~~g~Go!", 3000, 3);

SetPlayerRaceCheckpoint(playerid, cfgRace, CheckpointCoord[0][1], CheckpointCoord[1][1], CheckpointCoord[2][1], CheckpointCoord[0][2], CheckpointCoord[1][2], CheckpointCoord[2][2], 14.0);

}

return 1;

}

public OnPlayerCommandText(playerid, cmdtext[])

{

    new tmp[128],idx;

    tmp = strtok(cmdtext, idx);

if(strcmp(tmp, "/race", true) == 0)

{

    if(IsPlayerAdmin(playerid))

{

    if(cfgRace != 255)

    {

    tmp = strtok(cmdtext, idx);

if(!strlen(tmp))

{

SendClientMessage(playerid, 0xAFAFAFAA, "ERROR: /race [iD]");

SendClientMessage(playerid, 0xFF6347AA, "| 1: Create checkpoint at current pos | 2: delete previous checkpoint | 3: delete all checkpoints");

SendClientMessage(playerid, 0xFF6347AA, "| 4: start race (only for you) | 5: start race (for all)");

    format(tmp,sizeof(tmp),"  Current checkpoint-id: %d",CheckpointsSetted);

SendClientMessage(playerid,0xAFAFAFAA,tmp);

return 1;

}

new raceid = strval(tmp);

        if (raceid == 1)

{

    if(CheckpointsSetted < MAX_RACE_CPS)

{

new Float:GetX, Float:GetY, Float:GetZ;

GetPlayerPos(playerid, GetX, GetY, GetZ);

    CheckpointsSetted++;

    CheckpointCoord[0][CheckpointsSetted] = GetX;

    CheckpointCoord[1][CheckpointsSetted] = GetY;

    CheckpointCoord[2][CheckpointsSetted] = GetZ;

format(tmp, sizeof(tmp), "[tRace]: Checkpoint number %d successfully created.", CheckpointsSetted);

SendClientMessage(playerid, 0x9ACD32AA, tmp);

} else {

    format(tmp,sizeof(tmp),"[tRace]: You have created to much checkpoints, allowed are a maximum of %d!",MAX_RACE_CPS);

SendClientMessage(playerid,0xAFAFAFAA,tmp);

}

return 1;

}

else if(raceid == 2)

{

if(CheckpointsSetted != 0)

    {

    format(tmp,sizeof(tmp),"[tRace]: Checkpoint ID %d deleted!",CheckpointsSetted);

SendClientMessage(playerid,0x9ACD32AA,tmp);

    CheckpointsSetted--;

    } else {

    format(tmp,sizeof(tmp),"[tRace]: You have to create %d checkpoints to delete your last!",CheckpointsSetted);

SendClientMessage(playerid,0xAFAFAFAA,tmp);

}

}

else if(raceid == 3)

{

if(CheckpointsSetted > 0)

    {

SendClientMessage(playerid,0x9ACD32AA,"[tRace]: All checkpoints reseted/deleted.");

    CheckpointsSetted = 0;

    } else SendClientMessage(playerid,0xAFAFAFAA,"[tRace]: There is no checkpoint could be deleted!");

}

else if(raceid == 4)

{

if(CheckpointsSetted >= MIN_RACE_CPS)

    {

        SendClientMessage(playerid,0x9ACD32AA,"  The race with the checkpoints that you've placed (only visible for you) starts!");

        whichCP[playerid] = 1;

SetPlayerRaceCheckpoint(playerid, cfgRace, CheckpointCoord[0][1], CheckpointCoord[1][1], CheckpointCoord[2][1], CheckpointCoord[0][2], CheckpointCoord[1][2], CheckpointCoord[2][2], 14.0);

    } else {

    format(tmp,sizeof(tmp),"[tRace]: You have created %d checkpoints, but there must be at least %d!",CheckpointsSetted,MIN_RACE_CPS);

SendClientMessage(playerid,0xAFAFAFAA,tmp);

}

}

else if(raceid == 5)

{

if(CheckpointsSetted >= MIN_RACE_CPS)

    {

    tmp = strtok(cmdtext, idx);

if(!strlen(tmp)) return SendClientMessage(playerid, 0xAFAFAFAA, "ERROR: /race 5 [countdowntime (ex. 15)]");

new counttime = strval(tmp);

if(counttime < 1 && counttime > 61) return SendClientMessage(playerid, 0xAFAFAFAA,"ERROR: The countdowntime can not lay under 1 and over 60!");

          foreach(Player,i)

        {

StartRaceWithCountdown(i,counttime+1,0);

}

        SendClientMessage(playerid,0x9ACD32AA,"  The race with the checkpoints that you've placed (only visible for you) starts!");

    } else {

    format(tmp,sizeof(tmp),"[tRace]: You have created %d checkpoints, but there must be at least %d!",CheckpointsSetted,MIN_RACE_CPS);

SendClientMessage(playerid,0xAFAFAFAA,tmp);

}

}

}

else

{

tmp = strtok(cmdtext, idx);

if(!strlen(tmp))

{

SendClientMessage(playerid, 0xFF6347AA, "ERROR: You have to configure the type of race first (in which form the checkpoints should be displayed).");

SendClientMessage(playerid, 0xFF6347AA, "ERROR: Type noe one of the ID's [/race (1/2)] to unlock the next options");

SendClientMessage(playerid, 0xB4B5B7FF, "RACE-ID: 1: Normal (car/boat/on-foot) | 2: Airplane");

return 1;

}

new cfgid = strval(tmp);

if(cfgid == 1)

{

SendClientMessage(playerid, 0x9ACD32AA, "[tRace]: You've choose the racing mode 1 (car/boat/on-foot). From now on only regular checkpoints will be created.");

    cfgRace = 0;

}

else if(cfgid == 2)

{

SendClientMessage(playerid, 0x9ACD32AA, "[tRace]: You've choose the racing mode 1 (car/boat/on-foot). From now on only regular checkpoints will be created.");

    cfgRace = 3;

}

return 1;

}

} else SendClientMessage(playerid,0xAFAFAFAA,"  You are not an admin!");

    return 1;

}

return 0;

}

public OnPlayerEnterRaceCheckpoint(playerid)

{

    if(CheckpointsSetted > 0)

    {

        if(whichCP[playerid] == CheckpointsSetted)

    {

        placement++;

        new string[128], racername[MAX_PLAYER_NAME];

        GetPlayerName(playerid, racername, sizeof(racername));

        if(placement == 1)

{

    format(string, sizeof(string), "*%d*: %s has reached all checkpoints and became the first!", placement,racername);

      SendClientMessageToAll(0xB8860BAA, string);

      GivePlayerMoney(playerid,5000);

GameTextForPlayer(playerid, "~g~+$5000", 5000, 1);

}

else if(placement == 2)

{

format(string, sizeof(string), "*%d*: %s has reached all checkpoints and was the second!", placement,racername);

      SendClientMessageToAll(0xC0C0C0FF, string);

      GivePlayerMoney(playerid,3000);

GameTextForPlayer(playerid, "~g~+$3000", 5000, 1);

}

else if(placement == 3)

{

    format(string, sizeof(string), "*%d*: %s has reached all checkpoints and was the third!", placement,racername);

      SendClientMessageToAll(0x9ACD32AA, string);

      GivePlayerMoney(playerid,1000);

GameTextForPlayer(playerid, "~g~+$1000", 5000, 1);

}

else

{

    format(string, sizeof(string), "*%d*: %s has reached all checkpoints and is now on the %d place!", placement,racername,placement);

      SendClientMessageToAll(0x9ACD32AA, string);

}

  PlayerPlaySound(playerid,1057,0.0,0.0,0.0);

      DisablePlayerRaceCheckpoint(playerid);

        whichCP[playerid] = 0;

        return 1;

  }

  else if(whichCP[playerid] == CheckpointsSetted-1)

  {

  whichCP[playerid] += 1;

SetPlayerRaceCheckpoint(playerid, 1, CheckpointCoord[0][whichCP[playerid]], CheckpointCoord[1][whichCP[playerid]], CheckpointCoord[2][whichCP[playerid]], 0.0, 0.0, 0.0, 14.0);

  return 1;

  }

  PlayerPlaySound(playerid, 1137, 0.0, 0.0, 0.0);

whichCP[playerid] += 1;

  SetPlayerRaceCheckpoint(playerid, cfgRace, CheckpointCoord[0][whichCP[playerid]], CheckpointCoord[1][whichCP[playerid]], CheckpointCoord[2][whichCP[playerid]], CheckpointCoord[0][whichCP[playerid]+1], CheckpointCoord[1][whichCP[playerid]+1], CheckpointCoord[2][whichCP[playerid]+1], 14.0);

  return 1;

}

return 1;

}

strtok(const string[], &index)

{

new length = strlen(string);

while ((index < length) && (string[index] <= ' '))

{

index++;

}

new offset = index;

new result[20];

while ((index < length) && (string[index] > ' ') && ((index - offset) < (sizeof(result) - 1)))

{

result[index - offset] = string[index];

index++;

}

result[index - offset] = EOS;

return result;

}[/pawn]

0 answers to this question

Recommended Posts

There have been no answers to this question yet

Guest
This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. For more details you can also review our Terms of Use and Privacy Policy.