All pastes #960145 Raw Edit

Anonymous

public text v1 · immutable
#960145 ·published 2008-03-27 22:12 UTC
rendered paste body
#include <float>
#include <a_samp>

#define COLOR_GREEN 0x33AA33AA
#define COLOR_GREY 0xAFAFAFAA
#define COLOR_GREEN2 0x00CC00AA
#define COLOR_RED 0xFF0000FF
#define COLOR_YELLOW 0xFFFF00AA
#define COLOR_WHITE 0xFFFFFFAA
#define COLOR_BLUE 0x0000BBAA
#define COLOR_LIGHTBLUE 0x33CCFFAA
#define COLOR_ORANGE 0xFF9900AA
#define COLOR_SYSTEM 0xC6BEBDFF
#define CP_START 0
#define CP_FINISH 1

new osoby;
new stawka;
new race;

new PlayerRace[MAX_PLAYERS];
new PlayerCheckpoint[MAX_PLAYERS];
new Float:sx, Float:sy, Float:sz;
new Float:fx, Float:fy, Float:fz;
new Odliczanie[MAX_PLAYERS];
new manager;
new PlayersInRace;
new Float:Angle;
new Start[MAX_PLAYERS];
new VehModelID;
new Czas[MAX_PLAYERS] = 6;
new PlayerInFinish;
main(){print("\n+----------------------------------+");
print("|    2 Fast 2 Furious GameMode     |");
print("|           Coded By               |");
print("|             Mruk                 |");
print("+----------------------------------+\n");}
public OnGameModeInit(){
SetWorldTime(0);
UsePlayerPedAnims();
SetGameModeText("2 Fast 2 Furious PL");

AddPlayerClass(265,1958.3783,1343.1572,15.3746,270.1425,0,0,24,300,-1,-1);
AddPlayerClass(266,1958.3783,1343.1572,15.3746,270.1425,0,0,24,300,-1,-1);
AddPlayerClass(267,1958.3783,1343.1572,15.3746,270.1425,0,0,24,300,-1,-1);
AddPlayerClass(268,1958.3783,1343.1572,15.3746,269.1425,0,0,24,300,-1,-1);
AddPlayerClass(269,1958.3783,1343.1572,15.3746,269.1425,0,0,24,300,-1,-1);
AddPlayerClass(270,1958.3783,1343.1572,15.3746,269.1425,0,0,24,300,-1,-1);
AddPlayerClass(271,1958.3783,1343.1572,15.3746,269.1425,0,0,24,300,-1,-1);
AddPlayerClass(272,1958.3783,1343.1572,15.3746,269.1425,0,0,24,300,-1,-1);
AddPlayerClass(280,1958.3783,1343.1572,15.3746,270.1425,0,0,24,300,-1,-1);

return 1;
}
public OnPlayerSpawn(playerid){
SetPlayerInterior(playerid, 0);
GivePlayerMoney(playerid, 20000);
}
public OnPlayerCommandText(playerid, cmdtext[]){
new cmd[256];
new idx;
new string[256];

cmd = strtok(cmdtext, idx);

if(strcmp(cmd, "/race", true) == 0)
{
new tmp[256];
tmp = strtok(cmdtext, idx);

if(!strlen(tmp)){
SendClientMessage(playerid, COLOR_RED, "** Wpisz: /race [stawka] [ilość osób jaka może wziąć udział w wyścigu (2-10)]");
return 1;
}
stawka = strval(tmp);
tmp = strtok(cmdtext, idx);

if(!strlen(tmp)){
SendClientMessage(playerid, COLOR_RED, "Wpisz: /race [stawka] [ilość osób jaka może wziąć udział w wyścigu (2-10)]");
return 1;
}
osoby = strval(tmp);
/*if(osoby < 2 || osoby > 10){
SendClientMessage(playerid, COLOR_RED, "Ilość osób jaka może wziąć udział w wyścigu nie może być większa od 10 i mniejsza od 2.");
return 1;
}*/

if(race == 1){
SendClientMessage(playerid, COLOR_RED, "Aktualnie jest jakiś wyścig,  spróbuj ponownie po jego zakończeniu.");
return 1;
}
if(GetPlayerMoney(playerid) < stawka){
format(string, 256, "Nie masz $%d", stawka);
SendClientMessage(playerid, COLOR_RED, string);
return 1;
}
race = 1;
PlayerRace[playerid] = 1;
manager = 1;
SendClientMessage(playerid, COLOR_RED, "Doskonale! Teraz podjedź do miejsca w którym ma się zaczynać wyścig i wpisz /start");
SendClientMessage(playerid, COLOR_RED, "następnie podjedź tam gdzie ma się kończyć wyści i wpisz /finish.");
SendClientMessage(playerid, COLOR_GREEN, "Czas oczekiwania na graczy: 2min.");
format(string, 256, "Stawka Wyścigu: %d", stawka);
SendClientMessage(playerid, COLOR_GREEN, string);
format(string, 256, "Limit osób które mogą uczestniczyć w wyścigu: %d", osoby);
SendClientMessage(playerid, COLOR_GREEN, string);
//SendClientMessage(playerid, COLOR_RED, "Jedź do Punktu Kontrolnego (Czerwony punkt na radarze).");

GivePlayerMoney(playerid, -stawka);
return 1;
}

if(strcmp(cmd, "/start", true) == 0)
{
if(PlayerRace[playerid] == 0){
SendClientMessage(playerid, COLOR_RED, "Nie rozpoczełeś żadnego wyścigu.");
return 1;
}
if(!IsPlayerInAnyVehicle(playerid)){
SendClientMessage(playerid, COLOR_GREY, "Musisz być w pojeździe.");
return 1;
}
SendClientMessage(playerid, COLOR_BLUE, "Ok, więc TU, będzie się zaczynał wyścig. Teraz jeszcze zaznacz mete komendą /finish.");
manager = 1;
GetPlayerPos(playerid, sx,sy,sz);
GetVehicleZAngle(GetPlayerVehicleID(playerid), Angle);
for(new i=0; i<MAX_PLAYERS; i++){
if(IsPlayerConnected(playerid)){
//if(PlayerRace[i] == 0){
SetPlayerCheckpoint(i, sx,sy,sz, 5.5);
PlayerCheckpoint[i] = CP_START;

}}//}
Start[playerid] = 1;
return 1;
}
if(strcmp(cmd, "/finish", true) == 0)
{
if(PlayerRace[playerid] == 0){
SendClientMessage(playerid, COLOR_RED, "Nie rozpoczełeś żadnego wyścigu.");
return 1;
}
if(Start[playerid] == 0){
SendClientMessage(playerid, COLOR_RED, "Nie zaznaczyłeś początku wyścigu. Do tego użyj komendy /start.");
return 1;
}
if(!IsPlayerInAnyVehicle(playerid)){
SendClientMessage(playerid, COLOR_GREY, "Musisz być w pojeździe.");
return 1;
}
if(PlayerToPoint(20.0, playerid, sx, sy, sz)){
SendClientMessage(playerid, COLOR_RED, "Haha, taki krótki wyścig? Dystans musi być większy!");
return 1;
}DisablePlayerCheckpoint(playerid);
SetVehiclePos(GetPlayerVehicleID(playerid), sx, sy, sz);
SetVehicleZAngle(GetPlayerVehicleID(playerid), Angle);
SetCameraBehindPlayer(playerid);
SendClientMessage(playerid, COLOR_BLUE, "Ok, więc TU, będzie się kończył wyścig.");
GetPlayerPos(playerid, fx,fy,fz);
//SetPlayerCheckpoint(playerid, x,y,z, 5.5);
SendClientMessage(playerid, COLOR_RED, "Zostałeś Automatycznie teleportowany do miejsca startu.");
/*for(new i=0; i<MAX_PLAYERS; i++){
if(IsPlayerConnected(playerid)){
//if(PlayerRace[i] == 0){*/

//}}//}
//SendClientMessage(playerid, COLOR_RED, "Ustaw się tak, abyś dobrze wystartował i wpisz /gotowy.");
format(string, 256, "SMS: Chcesz się pościgać a za razem zarobić troche kasy? Jedź do punktu kotrolnego!");
SendClientMessageToAll(COLOR_YELLOW, string);
format(string, 256, "Stawka wyścigu: $%d. Liczba osob które mogą uczetniczyć: %d.", stawka, osoby);
SendClientMessageToAll(COLOR_YELLOW, string);
SetTimerEx("WaitingTime", 120*1000, 0, "d", playerid);
TogglePlayerControllable(playerid, 0);
manager = 0;
VehModelID = GetPlayerVehicleID(playerid);
SetTimerEx("SetFinishCP", 750, 0, "d", playerid);
PlayersInRace++;
return 1;
}
return 0;
}

public OnPlayerRequestClass(playerid, classid)
{
SetupPlayerForClassSelection(playerid);
return 1;
}
forward SetupPlayerForClassSelection(playerid);
public SetupPlayerForClassSelection(playerid)
{
SetPlayerInterior(playerid,14);
SetPlayerPos(playerid,258.4893,-41.4008,1002.0234);
SetPlayerFacingAngle(playerid, 270.0);
SetPlayerCameraPos(playerid,256.0815,-43.0475,1004.0234);
SetPlayerCameraLookAt(playerid,258.4893,-41.4008,1002.0234);
}

public OnPlayerEnterCheckpoint(playerid){
new string[256];
switch(PlayerCheckpoint[playerid]){
case CP_START:{
if(!IsPlayerInAnyVehicle(playerid)){
SendClientMessage(playerid, COLOR_GREY, "Musisz być w pojeździe.");
return 1;
}
if(manager == 1){return 1;}
new Float:vx, Float:vy, Float:vz;
osoby--;
PlayersInRace++;
PlayerRace[playerid] = 1;
GetVehiclePos(VehModelID, vx, vy, vz);
GetXYOnSideOfVehicle(VehModelID, vx, vy, 5.0);
SetVehiclePos(GetPlayerVehicleID(playerid), vx, vy, vz);
DisablePlayerCheckpoint(playerid);
SetPlayerCheckpoint(playerid, fx,fy,fz, 5.5);
format(string, 256, "Oczekiwania na innych zawodników. Pozostało 2 minut oczekiwania, i pozostało %d wolnych miejsc.", osoby);
SendClientMessage(playerid, COLOR_GREEN, string);
if(osoby == 0){
for(new i=0; i<MAX_PLAYERS; i++){
if(IsPlayerConnected(i)){
if(PlayerRace[i] == 1){
format(string, 256, "Są już wszyscy zawodnicy. Rozpoczynamy odliczanie.");
SendClientMessage(i, COLOR_GREEN, string);
Odliczanie[i] = SetTimerEx("CountDown", 1000, 1, "d", i);
TogglePlayerControllable(i, 0);
}}}
return 1;
}
}
case CP_FINISH:{
PlayerInFinish++;
DisablePlayerCheckpoint(playerid);
if(PlayerInFinish == 1){
format(string, 256, "Gratulacje zdobyłeś 1-sze miejsce i wygrałeś $%d.", stawka*70/100);
SendClientMessage(playerid, COLOR_GREEN, string);
GivePlayerMoney(playerid, stawka*70/100);
}
else if(PlayerInFinish == 2){
format(string, 256, "Zdobyłeś 2-gie miejsce i zarobiłeś tylko $%d.", stawka*20/100);
SendClientMessage(playerid, COLOR_GREEN, string);
GivePlayerMoney(playerid, stawka*25/100);
}
else if(PlayerInFinish == 3){
format(string, 256, "Zajełeś 3-miejsce i wygrałeś marne $%d", stawka*10/100);
SendClientMessage(playerid, COLOR_GREEN, string);
GivePlayerMoney(playerid, stawka*70/100);
}
else if(PlayerInFinish >= 4){
format(string, 256, "Zajełeś %d miejsce, nie wygrałeś żadnej gotówki.", PlayerInFinish);
SendClientMessage(playerid, COLOR_GREEN, string);
}
if(PlayerInFinish == PlayersInRace){
race = 0;
PlayersInRace = 0;
PlayerRace[playerid] = 0;
osoby = 0;
stawka = 0;
PlayerInFinish = 0;
manager = 0;
SendClientMessage(playerid, COLOR_GREEN, "Ogłoszenie: Właśnie skończył się bierzący wyścig. Można rozpocząć następny.");
}
}
}
return 1;
}
forward SetFinishCP(playerid);
public SetFinishCP(playerid){
SetPlayerCheckpoint(playerid, fx,fy,fz, 5.5);
PlayerCheckpoint[playerid] = CP_FINISH;
}
forward CountDown(playerid);
public CountDown(playerid){
for(new i=0; i<MAX_PLAYERS; i++){
if(IsPlayerConnected(i)){
if(PlayerRace[i] == 1){
Czas[i]--;
new string[256];
format(string, sizeof(string), "~n~~n~~n~~n~~n~~n~~n~~g~Pozostalo: ~r~%d ~y~Sekund.", Czas[i]);
GameTextForPlayer(playerid, string, 1000, 5);
if(Czas[i] == 0){
KillTimer(Odliczanie[i]);
Czas[i] = 6;
TogglePlayerControllable(i, 1);
}}}}
}
forward WaitingTime(playerid);
public WaitingTime(playerid){
Odliczanie[playerid] = SetTimerEx("CountDown", 1000, 1, "d", playerid);
}
forward PlayerToPoint(Float:radi, playerid, Float:x, Float:y, Float:z);
public PlayerToPoint(Float:radi, playerid, Float:x, Float:y, Float:z)
{
if(IsPlayerConnected(playerid))
{
new Float:oldposx, Float:oldposy, Float:oldposz;
new Float:tempposx, Float:tempposy, Float:tempposz;
GetPlayerPos(playerid, oldposx, oldposy, oldposz);
tempposx = (oldposx -x);
tempposy = (oldposy -y);
tempposz = (oldposz -z);
//printf("DEBUG: X:%f Y:%f Z:%f",posx,posy,posz);
if (((tempposx < radi) && (tempposx > -radi)) && ((tempposy < radi) && (tempposy > -radi)) && ((tempposz < radi) && (tempposz > -radi)))
{
return 1;
}
}
return 0;
}
GetXYOnSideOfVehicle(vehicleid, &Float:x, &Float:y, Float:distance)
{
	new Float:a;
	GetVehiclePos(vehicleid, x, y, a);
	GetVehicleZAngle(vehicleid, a);
	a += 90.0;
	x += (distance * floatsin(-a, degrees));
	y += (distance * floatcos(-a, degrees));
	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;
}