Sziasztok!
Angol fórumról hoztam egy verseny scriptet. Természetesen magyarosítva.
Eredeti téma:
http://forum.sa-mp.com/showthread.php?t=300196Eredeti Készítõ : JaST
Letöltés:
http://www.2shared.com/file/YnH4P6gQ/Drag_FS.html[pawn]// Drag system filterscript
// ˆ JaST 2011
//
www.4samp.tk// Magyarosította: Dream
#include <a_samp>
#define DIALOG_INVITE 763
#define DIALOG_DRAG_PRICE 764
#define DIALOG_DRAG_ACCEPT 765
new participantCar[MAX_PLAYERS];
new PlayerInDrag[MAX_PLAYERS],DragPrice[MAX_PLAYERS],InvitedPlayer[MAX_PLAYERS],InviteSender[MAX_PLAYERS];
forward DragEnd(dragid,winner); forward CountDown33(playerid, seconds);
public OnFilterScriptInit()
{
print(\"Drag system Filterscript by JaST\");
return 1;
}
public OnPlayerConnect(playerid)
{
PlayerInDrag[playerid] = -1; DragPrice[playerid] = -1; InvitedPlayer[playerid] = -1; InvitedPlayer[playerid] = -1;
return 1;
}
public OnPlayerDisconnect(playerid, reason)
{
if(PlayerInDrag[playerid] != -1)
{
if(PlayerInDrag[playerid] == playerid) return DragEnd(PlayerInDrag[playerid],InvitedPlayer[playerid]);
else if(PlayerInDrag[playerid] == InviteSender[playerid]) return DragEnd(PlayerInDrag[playerid],InviteSender[playerid]);
}
return 1;
}
public OnPlayerSpawn(playerid)
{
if(PlayerInDrag[playerid] != -1)
{
if(PlayerInDrag[playerid] == playerid) return DragEnd(PlayerInDrag[playerid],InvitedPlayer[playerid]);
else if(PlayerInDrag[playerid] == InviteSender[playerid]) return DragEnd(PlayerInDrag[playerid],InviteSender[playerid]);
}
return 1;
}
public OnPlayerCommandText(playerid, cmdtext[])
{
if (strcmp(\"/drag\", cmdtext, true, 10) == 0)
{
if(PlayerInDrag[playerid] != -1) return SendClientMessage(InviteSender[playerid], 0xFFFFFFAA, \" SERVER: Nem használhatod a parancsot a versenyben.\");
ShowPlayerDialog(playerid,DIALOG_INVITE,DIALOG_STYLE_INPUT,\"Játékos meghívása\",\"\\nÍrd be a játékos ID-jét:\\n\",\"Következõ.\",\"Mégse.\");
return 1;
}
return 0;
}
public OnPlayerExitVehicle(playerid, vehicleid)
{
if(PlayerInDrag[playerid] != -1)
{
if(PlayerInDrag[playerid] == playerid) return DragEnd(PlayerInDrag[playerid],InvitedPlayer[playerid]);
else if(PlayerInDrag[playerid] == InviteSender[playerid]) return DragEnd(PlayerInDrag[playerid],InviteSender[playerid]);
}
return 1;
}
public OnPlayerEnterCheckpoint(playerid)
{
if(PlayerInDrag[playerid] != -1)
{
DragEnd(PlayerInDrag[playerid],playerid);
}
return 1;
}
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
if(dialogid == DIALOG_INVITE)
{
if(response)
{
new sendto = strval(inputtext);
if(sendto == INVALID_PLAYER_ID || PlayerInDrag[sendto] != -1 || InviteSender[sendto] != -1) return SendClientMessage(playerid, 0xFFFFFFAA, \" SERVER: A játékos nem elérhetõ, vagy már versenyben van.\");
if(sendto == playerid) return SendClientMessage(playerid, 0xFFFFFFAA, \" SERVER: Magadat nem hívhatod ki!\");
ShowPlayerDialog(playerid,DIALOG_DRAG_PRICE,DIALOG_STYLE_INPUT,\"Meghívás\",\"\\nÍrd be a tétet:\\n\",\"Következõ\",\"Mégse\");
InvitedPlayer[playerid] = sendto; // Invite player id
}
}
if(dialogid == DIALOG_DRAG_PRICE)
{
if(response)
{
new sendto = InvitedPlayer[playerid];
if(!strlen(inputtext) || PlayerInDrag[sendto] != -1) return ShowPlayerDialog(playerid,DIALOG_DRAG_PRICE,DIALOG_STYLE_INPUT,\"Invite player to drag\",\"\\nYou can not start without a bet! \\nEnter the amount you want to bet\\n\",\"Next\",\"Cancel\");
new sendername[128],string[128],price = strval(inputtext);
GetPlayerName(playerid, sendername, sizeof(sendername));
DragPrice[playerid] = price; // Bet
InviteSender[sendto] = playerid; // Invite Sender Player ID
format(string, sizeof(string), \" Meghívott egy versenyre: %s \\n Tét: $%d\", sendername, price);
ShowPlayerDialog(sendto,DIALOG_DRAG_ACCEPT,DIALOG_STYLE_MSGBOX,\"Invite\",string,\"Elfogad\",\"Elutasít\");
}
else
{
InvitedPlayer[playerid] = -1;
}
}
if(dialogid == DIALOG_DRAG_ACCEPT)
{
new sender = InviteSender[playerid];
if(response)
{
new player_1 = InviteSender[playerid],player_2 = playerid;
PlayerInDrag[player_1] = player_1;
PlayerInDrag[player_2] = player_1;
SetPlayerVirtualWorld(player_1,player_1);
SetPlayerVirtualWorld(player_2,player_1);
participantCar[player_1] = AddStaticVehicle(411,-2675.7930,1346.1169,55.1568,359.0356,1,1);
participantCar[player_2] = AddStaticVehicle(411,-2686.9407,1346.3988,55.1568,0.5639,1,1);
SetVehicleVirtualWorld(participantCar[player_1],player_1);
SetVehicleVirtualWorld(participantCar[player_2],player_1);
PutPlayerInVehicle(player_1,participantCar[player_1],0);
PutPlayerInVehicle(player_2,participantCar[player_2],0);
SetPlayerCheckpoint(player_1, -2681.7556,2148.9546,55.8125, 15.0);
SetPlayerCheckpoint(player_2, -2681.7556,2148.9546,55.8125, 15.0);
TogglePlayerControllable(player_1, 0);
TogglePlayerControllable(player_2, 0);
CountDown33(player_1, 5);
}
else
{
//Sender Invite Clear
SendClientMessage(InviteSender[playerid], 0xFFFFFFAA, \" [DRAG] Játékos elutasította a meghívásod.!\");
DragPrice[sender] = -1;
InvitedPlayer[sender] = -1;
//Invited Player Clear
InviteSender[playerid] = -1;
}
}
return 1;
}
public OnPlayerClickPlayer(playerid, clickedplayerid, source)
{
return 1;
}
public CountDown33(playerid, seconds)
{
new string[256];
if(seconds > 0)
{
format(string, sizeof(string), \"~R~%d\", seconds);
GameTextForPlayer(playerid, string, 1000, 3);
GameTextForPlayer(InvitedPlayer[playerid], string, 1000, 3);
seconds = seconds -1;
SetTimerEx(\"CountDown33\", 1000, 0, \"ii\", playerid, seconds);
SetTimerEx(\"CountDown33\", 1000, 0, \"ii\", InvitedPlayer[playerid], seconds);
return 1;
}
if(seconds == 0)
{
GameTextForPlayer(playerid, \"~G~MEHET!!!\", 1000, 3);
GameTextForPlayer(InvitedPlayer[playerid], \"~G~MEHET!!!\", 1000, 3);
TogglePlayerControllable(playerid, 1);
TogglePlayerControllable(InvitedPlayer[playerid], 1);
return 1;
}
return 1;
}
public DragEnd(dragid,winner)
{
GivePlayerMoney(winner,DragPrice[dragid]);
DestroyVehicle(participantCar[winner]);
SetPlayerVirtualWorld(winner,0);
DisablePlayerCheckpoint(winner);
PlayerInDrag[winner] = -1;
SpawnPlayer(winner);
if(winner == dragid)
{
DestroyVehicle(participantCar[invitedPlayer[winner]]);
DisablePlayerCheckpoint(InvitedPlayer[winner]);
SetPlayerVirtualWorld(InvitedPlayer[winner],0);
SpawnPlayer(InvitedPlayer[winner]);
GivePlayerMoney(InvitedPlayer[winner],-DragPrice[dragid]);
PlayerInDrag[invitedPlayer[winner]] = -1;
InviteSender[invitedPlayer[winner]] = -1;
InvitedPlayer[winner] = -1;
}
else
{
DestroyVehicle(participantCar[inviteSender[winner]]);
SetPlayerVirtualWorld(InviteSender[winner],0);
SpawnPlayer(InviteSender[winner]);
GivePlayerMoney(InviteSender[winner],-DragPrice[dragid]);
DisablePlayerCheckpoint(InviteSender[winner]);
PlayerInDrag[inviteSender[winner]] = -1;
InvitedPlayer[inviteSender[winner]] = -1;
InviteSender[winner] = -1;
}
new string[128],winnername[MAX_PLAYER_NAME];
GetPlayerName(winner, winnername, sizeof(winnername));
format(string, sizeof(string), \"[DRAG] %s megnyerte a versenyt. Nyereménye: $%d \", winnername,DragPrice[dragid]*2);
SendClientMessageToAll(0x00D900AA, string);
DragPrice[dragid] = -1;
return 1;
}[/pawn]