21.01.2012, 19:14
(
Последний раз редактировалось Jorge_Braz; 21.01.2012 в 20:49.
)
Venho aqui postar mais um trabalho meu !
Sistema de Racha para 2 player ( Claro й racha rs)
Faзam bom Uso !
Sistema de Racha para 2 player ( Claro й racha rs)
Faзam bom Uso !
pawn Код:
#include <a_samp>
new carroDU[2];
new correndo[MAX_PLAYERS];
new corrida = 0;
new cashp = 0;
new desafiante;
new colocado = 0;
new correndos[MAX_PLAYERS];
stock PlayerName(playerid)
{
new Name[MAX_PLAYER_NAME];
GetPlayerName(playerid, Name, MAX_PLAYER_NAME);
return Name;
}
new Float:carroe[2][4] = //4 = 4 coordenadas | 3 = 3 "valores" (X,Y,Z)
{
{2062.4832,-1810.0673,13.0877,91.2496},
{2059.8037,-1815.0095,13.0877,90.4774}
};
new Float:racha[5][3] = //4 = 4 coordenadas | 3 = 3 "valores" (X,Y,Z)
{
{1965.8903,-1812.1543,13.0874},
{1960.6847,-1918.1187,13.0883},
{1961.8507,-2163.1030,13.0868},
{1823.5540,-2165.9551,13.0879},
{1822.8104,-2026.0538,13.0867}
};
public OnFilterScriptInit()
{
print("\n--------------------------------------");
print(" Blank Filterscript by your name here");
print("--------------------------------------\n");
return 1;
}
public OnFilterScriptExit()
{
return 1;
}
public OnPlayerRequestClass(playerid, classid)
{
SetPlayerPos(playerid, 1958.3783, 1343.1572, 15.3746);
SetPlayerCameraPos(playerid, 1958.3783, 1343.1572, 15.3746);
SetPlayerCameraLookAt(playerid, 1958.3783, 1343.1572, 15.3746);
return 1;
}
stock 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;
}
stock strtokEx(const string[], &index)
{
new length = strlen(string);
while ((index < length) && (string[index] <= ' '))
{
index++;
}
new offset = index;
new result[64];
while ((index < length) && ((index - offset) < (sizeof(result) - 1)))
{
result[index - offset] = string[index];
index++;
}
result[index - offset] = EOS;
return result;
}
public OnPlayerCommandText(playerid, cmdtext[])
{
new cmd[128];
new tmp[128];
new string[128];
new idx;
cmd = strtok(cmdtext, idx);
if(strcmp(cmd, "/duelarc", true) == 0)
{
if(IsPlayerConnected(playerid))
{
tmp = strtok(cmdtext, idx);
if(!strlen(tmp))
{
SendClientMessage(playerid, 0xFFFFFFAA, "USE: /duelarc [id] [Aposta]");
return 1;
}
new playa;
new money;
playa = ReturnUser(tmp);
tmp = strtok(cmdtext, idx);
money = strval(tmp);
if(GetPlayerMoney(playerid) < money)
{
SendClientMessage(playerid,0xFFFFFFAA,"Vocк nгo tem Dinheiro Suficiente");
return 1;
}
if(corrida == 1)
{
SendClientMessage(playerid,0xFFFFFFAA,"Estб tendo um Racha");
return 1;
}
if(IsPlayerConnected(playa))
{
if(playa != INVALID_PLAYER_ID)
{
correndo[playerid] = 1;
carroDU[0] = CreateVehicle(434,carroe[0][0],carroe[0][1],carroe[0][2],carroe[0][3],1,0,60000);
cashp = money;
desafiante = playerid;
PutPlayerInVehicle(playerid, carroDU[0], 0);
TogglePlayerControllable(playerid, 0);
format(string,sizeof(string),"O Jogador %s Desafiou Vocк para uma Corrida , Aposta %d Cash !",PlayerName(playerid),money);
ShowPlayerDialog(playa,10,DIALOG_STYLE_MSGBOX,"Duelo",string,"Aceitar","Fechar");
}
}
}
return 1;
}
return 0;
}
public OnPlayerEnterRaceCheckpoint(playerid)
{
switch(correndos[playerid])
{
case 1:
{
DisablePlayerRaceCheckpoint(playerid);
SetPlayerRaceCheckpoint(playerid, 0, racha[1][0], racha[1][1], racha[1][2], racha[2][0], racha[2][1], racha[2][2], 10);
correndos[playerid] = 2;
}
case 2:
{
DisablePlayerRaceCheckpoint(playerid);
SetPlayerRaceCheckpoint(playerid, 0, racha[2][0], racha[2][1], racha[2][2], racha[3][0], racha[3][1], racha[3][2], 10);
correndos[playerid] = 3;
}
case 3:
{
DisablePlayerRaceCheckpoint(playerid);
SetPlayerRaceCheckpoint(playerid, 0, racha[3][0], racha[3][1], racha[3][2], racha[4][0], racha[4][1], racha[4][2], 10);
correndos[playerid] = 4;
}
case 4:
{
DisablePlayerRaceCheckpoint(playerid);
SetPlayerRaceCheckpoint(playerid, 1, racha[4][0], racha[4][1], racha[4][2], racha[4][0], racha[4][1], racha[4][2]-5, 10);
correndos[playerid] = 5;
}
case 5:
{
new strev[256];
DisablePlayerRaceCheckpoint(playerid);
colocado++;
switch(colocado)
{
case 1:
{
format(strev,sizeof(strev),"{ffffff}Vocк Chegou em {037b00}Primeiro {ffffff}Lugar no {037b00}Racha{ffffff} e Ganhou {037b00}%d Cash",cashp*2);
SendClientMessage(playerid,0xFFFFFFAA,strev);
format(strev,sizeof(strev),"{ffffff}O Jogador {037b00}%s{ffffff}Venceu o Racha e faturou {037b00}%d Cash",PlayerName(playerid),cashp*2);
SendClientMessageToAll(0xFFFFFFAA,strev);
DestroyVehicle(GetPlayerVehicleID(playerid));
correndo[playerid] = 0;
correndos[playerid] = 0;
corrida = 0;
GivePlayerMoney(playerid, cashp*2);
}
case 2:
{
format(strev,sizeof(strev),"{ffffff} Vocк {ff080e}perdeu {ffffff}o Racha ");
SendClientMessage(playerid,0xFFFFFFAA,strev);
cashp = 0;
correndo[playerid] = 0;
DestroyVehicle(GetPlayerVehicleID(playerid));
colocado = 0;
correndos[playerid] = 0;
desafiante = 0;
return 1;
}
}
}
}
return 1;
}
ReturnUser(text[], playerid = INVALID_PLAYER_ID)
{
new pos = 0;
while (text[pos] < 0x21) // Strip out leading spaces
{
if (text[pos] == 0) return INVALID_PLAYER_ID; // No passed text
pos++;
}
new userid = INVALID_PLAYER_ID;
if (IsNumeric(text[pos])) // Check whole passed string
{
// If they have a numeric name you have a problem (although names are checked on id failure)
userid = strval(text[pos]);
if (userid >=0 && userid < MAX_PLAYERS)
{
if(!IsPlayerConnected(userid))
{
/*if (playerid != INVALID_PLAYER_ID)
{
SendClientMessage(playerid, 0xFF0000AA, "User not connected");
}*/
userid = INVALID_PLAYER_ID;
}
else
{
return userid; // A player was found
}
}
/*else
{
if (playerid != INVALID_PLAYER_ID)
{
SendClientMessage(playerid, 0xFF0000AA, "Invalid user ID");
}
userid = INVALID_PLAYER_ID;
}
return userid;*/
// Removed for fallthrough code
}
// They entered [part of] a name or the id search failed (check names just incase)
new len = strlen(text[pos]);
new count = 0;
new name[MAX_PLAYER_NAME];
for (new i = 0; i < MAX_PLAYERS; i++)
{
if (IsPlayerConnected(i))
{
GetPlayerName(i, name, sizeof (name));
if (strcmp(name, text[pos], true, len) == 0) // Check segment of name
{
if (len == strlen(name)) // Exact match
{
return i; // Return the exact player on an exact match
// Otherwise if there are two players:
// Me and MeYou any time you entered Me it would find both
// And never be able to return just Me's id
}
else // Partial match
{
count++;
userid = i;
}
}
}
}
if (count != 1)
{
if (playerid != INVALID_PLAYER_ID)
{
if (count)
{
SendClientMessage(playerid, 0xFF0000AA, "Multiple users found, please narrow earch");
}
else
{
SendClientMessage(playerid, 0xFF0000AA, "No matching user found");
}
}
userid = INVALID_PLAYER_ID;
}
return userid; // INVALID_USER_ID for bad return
}
public OnVehicleStreamOut(vehicleid, forplayerid)
{
return 1;
}
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
if(dialogid == 10)
{
if(response)
{
TogglePlayerControllable(playerid, 0);
correndo[playerid] = 1;
GivePlayerMoney(desafiante, - cashp);
SetVehicleToRespawn(carroDU[1]);
carroDU[1] = CreateVehicle(434,carroe[1][0],carroe[1][1],carroe[1][2],carroe[1][3],1,0,60000);
PutPlayerInVehicle(playerid, carroDU[1], 0);
GivePlayerMoney(playerid, - cashp);
corrida = 1;
SetTimer("InicioCorrida", 1000, false);
}
else
{
TogglePlayerControllable(desafiante, 1);
cashp = 0;
SendClientMessage(desafiante,0xFFFF00AA," O Desafiado Recusou, Saia do Veiculo ");
return 1;
}
}
return 1;
}
forward InicioCorrida();
forward InicioCorrida2();
forward InicioCorrida3();
forward InicioCorrida4();
forward InicioCorrida5();
forward InicioCorridaGo();
public InicioCorrida()
{
for(new i = 0; i<MAX_PLAYERS; i++)
{
if(IsPlayerConnected(i))
{
if(correndo[i] == 1)
{
GameTextForPlayer(i, "5", 1001, 5);
PlayerPlaySound(i, 1056, 0.0, 0.0, 0.0);
}
}
}
SetTimer("InicioCorrida2", 1000, false);
return 1;
}
public InicioCorrida2()
{
for(new i = 0; i<MAX_PLAYERS; i++)
{
if(IsPlayerConnected(i))
{
if(correndo[i] == 1)
{
GameTextForPlayer(i, "4", 1001, 5);
PlayerPlaySound(i, 1056, 0.0, 0.0, 0.0);
}
}
}
SetTimer("InicioCorrida3", 1000, false);
return 1;
}
public InicioCorrida3()
{
for(new i = 0; i<MAX_PLAYERS; i++)
{
if(IsPlayerConnected(i))
{
if(correndo[i] == 1)
{
GameTextForPlayer(i, "3", 1001, 5);
PlayerPlaySound(i, 1056, 0.0, 0.0, 0.0);
}
}
}
SetTimer("InicioCorrida4", 1000, false);
return 1;
}
public InicioCorrida4()
{
for(new i = 0; i<MAX_PLAYERS; i++)
{
if(IsPlayerConnected(i))
{
if(correndo[i] == 1)
{
GameTextForPlayer(i, "2", 1001, 5);
PlayerPlaySound(i, 1056, 0.0, 0.0, 0.0);
}
}
}
SetTimer("InicioCorrida5", 1000, false);
return 1;
}
public InicioCorrida5()
{
for(new i = 0; i<MAX_PLAYERS; i++)
{
if(IsPlayerConnected(i))
{
if(correndo[i] == 1)
{
PlayerPlaySound(i, 1056, 0.0, 0.0, 0.0);
GameTextForPlayer(i, "1", 1001, 5);
}
}
}
SetTimer("InicioCorridaGo", 1000, false);
return 1;
}
IsNumeric(const string[])
{
for (new i = 0, j = strlen(string); i < j; i++)
{
if (string[i] > '9' || string[i] < '0') return 0;
}
return 1;
}
public InicioCorridaGo()
{
for(new i = 0; i<MAX_PLAYERS; i++)
{
if(IsPlayerConnected(i))
{
if(correndo[i] == 1)
{
GameTextForPlayer(i, "~r~VALENDO!", 1001, 5);
TogglePlayerControllable(i, 1);
correndos[i] = 1;
SetPlayerRaceCheckpoint(i, 0, racha[0][0], racha[0][1], racha[0][2], racha[1][0], racha[1][1], racha[1][2], 10);
}
}
}
return 1;
}