Szerző Téma: PING PONG vagyis PONG  (Megtekintve 888 alkalommal)

PING PONG vagyis PONG
« Dátum: 2013. június 29. - 02:22:23 »
+1 Show voters
Sziasztok találtam nektek a samp fórumon egy jó FS-t ami nem más mint ping pong,csak õ ugy hívja extreme pong.Ez a játék igy néz ki
 lehet több játékosal,max 2,és lehet NPCvel,(virtuális npc vagyis mint ha gép ellen mennél) A parancsai /pong elkezded a játékot,vagy /pong játékos id je akkor meghivod s elfogadja õ is akkor mehetek 2-en.Ha végezni akarsz a játékal akkor nyomj egy ENTERT és kilépsz belõle.
#include <a_samp>
#include <a_http>
#define MSPERFRAME          50   //Milliseconds per frame (decreasing this makes the game more smoother, but more resource hungry and faster)
#define Release          3   //The release version
//Dialog defines
#define DIALOG_NONE       0
#define DIALOG_CHECKPONG    1
#define DIALOG_ASKING      2
#define DIALOG_BEINGASKED   3
forward GameUpdate();
forward CheckUpdate(index, response_code, data[]);
forward UpdateDialog(playerid,time);
//TextDraws
new Text:Paddles[2];   //The paddles
new Text:Background;    //Black background to cover the screen
new Text:Net[4];        //The dotted line in the center
new Text:Score[2];      //The score on either side of the \'net\'
new Text:Ball;          //The ball
new TextDrawsCreated;   //0/1 if textdraws are created already
//Variables
new Players[2];                     //Maximum of 2 players
new PaddlePositions[2];             //The Y coordinate of the paddles (starting from the top)
new BallPosition[2];                //The X,Y Coordinate of the ball
new BallVelocity[2];                //The velocity of the ball (-5 through 5, X/Y velocities)
new Bot[2];                         //0/1 if player is a bot
new GameTimer;
new GameRunning;
new SoundChange;
new GameScore[2];
new pDialog[MAX_PLAYERS];
new pOpponent[MAX_PLAYERS];
new UpdateText[512];
new NewVersionAvailable;
//Functions
stock AffirmTextDraws()
{
if(TextDrawsCreated)return;
while(TextDrawCreate(0.0,0.0,\"~R~\")==Text:0)continue;
Background=TextDrawCreate(123,103,\"~r~\");
TextDrawUseBox(Background,1);
TextDrawBoxColor(Background,0x000000FF);
TextDrawTextSize(Background,520,0.0);
TextDrawLetterSize(Background,0,200*0.135);
Net[0]=TextDrawCreate(321,103,\"~r~\");
TextDrawUseBox(Net[0],1);
TextDrawBoxColor(Net[0],0xFFFFFFFF);
TextDrawTextSize(Net[0],322,0.0);
TextDrawLetterSize(Net[0],0,26.666*0.135);
Net[1]=TextDrawCreate(321,170,\"~r~\");
TextDrawUseBox(Net[1],1);
TextDrawBoxColor(Net[1],0xFFFFFFFF);
TextDrawTextSize(Net[1],322,0.0);
TextDrawLetterSize(Net[1],0,26.666*0.135);
Net[2]=TextDrawCreate(321,240,\"~r~\");
TextDrawUseBox(Net[2],1);
TextDrawBoxColor(Net[2],0xFFFFFFFF);
TextDrawTextSize(Net[2],322,0.0);
TextDrawLetterSize(Net[2],0,26.666*0.135);
Net[3]=TextDrawCreate(321,313.2,\"~r~\");
TextDrawUseBox(Net[3],1);
TextDrawBoxColor(Net[3],0xFFFFFFFF);
TextDrawTextSize(Net[3],322,0.0);
TextDrawLetterSize(Net[3],0,26.666*0.135);
Score[0]=TextDrawCreate(313,105,\"0\");
TextDrawColor(Score[0],0xFFFFFFFF);
TextDrawAlignment(Score[0],3);
TextDrawFont(Score[0],3);
TextDrawLetterSize(Score[0],0.5,15*0.135);
TextDrawSetShadow(Score[0],0);
Score[1]=TextDrawCreate(330,105,\"0\");
TextDrawColor(Score[1],0xFFFFFFFF);
TextDrawLetterSize(Score[1],0.5,15*0.135);
TextDrawFont(Score[1],3);
TextDrawSetShadow(Score[1],0);
Paddles[0]=TextDrawCreate(138,103,\"~r~\");
TextDrawUseBox(Paddles[0],1);
TextDrawBoxColor(Paddles[0],0xFFFFFFFF);
TextDrawTextSize(Paddles[0],139,0.0);
TextDrawLetterSize(Paddles[0],0,26.666*0.135);
Paddles[1]=TextDrawCreate(504,103,\"~r~\");
TextDrawUseBox(Paddles[1],1);
TextDrawBoxColor(Paddles[1],0xFFFFFFFF);
TextDrawTextSize(Paddles[1],505,0.0);
TextDrawLetterSize(Paddles[1],0,26.666*0.135);
Ball=TextDrawCreate(400,200,\"~r~\");
TextDrawUseBox(Ball,1);
TextDrawBoxColor(Ball,0xFFFFFFFF);
TextDrawTextSize(Ball,401,0.0);
TextDrawLetterSize(Ball,0,3*0.135);
TextDrawsCreated=1;
}
stock ShowPong(playerid)
{
TextDrawShowForPlayer(playerid,Paddles[0]);
TextDrawShowForPlayer(playerid,Paddles[0]);
TextDrawShowForPlayer(playerid,Paddles[1]);
TextDrawShowForPlayer(playerid,Paddles[1]);
TextDrawShowForPlayer(playerid,Background);
TextDrawShowForPlayer(playerid,Net[0]);
TextDrawShowForPlayer(playerid,Net[1]);
TextDrawShowForPlayer(playerid,Net[2]);
TextDrawShowForPlayer(playerid,Net[3]);
TextDrawShowForPlayer(playerid,Score[0]);
TextDrawShowForPlayer(playerid,Score[1]);
TextDrawShowForPlayer(playerid,Ball);
}
stock StartPong(player1,player2)
{
if(player1==INVALID_PLAYER_ID)Bot[0]=1;
else ShowPong(player1);
if(player2==INVALID_PLAYER_ID)Bot[1]=1;
else ShowPong(player2);
Players[0]=player1;
Players[1]=player2;
TogglePlayerControllable(player1,0);
TogglePlayerControllable(player2,0);
BallPosition[0]=200;
GameTimer=SetTimer(\"GameUpdate\",MSPERFRAME,1);
GameRunning=1;
AffirmTextDraws();
}
stock KillPong()
{
for(new i;i<2;i++)
{
TextDrawDestroy(Paddles);
TextDrawDestroy(Score);
}
for(new i;i<4;i++)TextDrawDestroy(Net);
TextDrawDestroy(Background);
TextDrawDestroy(Ball);
KillTimer(GameTimer);
GameScore[0]=0;
GameScore[1]=0;
TogglePlayerControllable(Players[0],1);
TogglePlayerControllable(Players[1],1);
GameRunning=0;
TextDrawsCreated=0;
}
stock PositionObjects()
{
if(TextDrawsCreated)
{
    TextDrawDestroy(Paddles[0]);
    TextDrawDestroy(Paddles[1]);
    TextDrawDestroy(Ball);
   
   
 
Paddles[0]=TextDrawCreate(138,103+PaddlePositions[0],\"~r~\");
TextDrawUseBox(Paddles[0],1);
TextDrawBoxColor(Paddles[0],0xFFFFFFFF);
TextDrawTextSize(Paddles[0],139,0.0);
TextDrawLetterSize(Paddles[0],0,26.666*0.135);
Paddles[1]=TextDrawCreate(504,103+PaddlePositions[1],\"~r~\");
TextDrawUseBox(Paddles[1],1);
TextDrawBoxColor(Paddles[1],0xFFFFFFFF);
TextDrawTextSize(Paddles[1],505,0.0);
TextDrawLetterSize(Paddles[1],0,26.666*0.135);
Ball=TextDrawCreate(123+BallPosition[0],103+BallPosition[1],\"~r~\");
TextDrawUseBox(Ball,1);
TextDrawBoxColor(Ball,0xFFFFFFFF);
TextDrawTextSize(Ball,124+BallPosition[0],0.0);
TextDrawLetterSize(Ball,0,2.5*0.135);
    ShowPong(Players[0]);
    ShowPong(Players[1]);
   
}
}
stock UpdateScore()
{
new tmp[5];
format(tmp,5,\"%02d\",GameScore[0]);
TextDrawSetString(Score[0],tmp);
format(tmp,5,\"%02d\",GameScore[1]);
TextDrawSetString(Score[1],tmp);
}
//Callbacks
public OnFilterScriptInit()
{
AffirmTextDraws();
HTTP(0, HTTP_GET, \"www.joestaff.net/updates/pong.txt\", \"\", \"CheckUpdate\");
}
public OnFilterScriptExit()
{
KillPong();
}
public OnPlayerCommandText(playerid,cmdtext[])
{
if(!strcmp(cmdtext,\"/pong\",true,5))
{
    if(GameRunning)return 1;
    if(strlen(cmdtext)<=6)StartPong(playerid,INVALID_PLAYER_ID);
    else
{
    if(!IsPlayerConnected(strval(cmdtext[6])))return SendClientMessage(playerid,0xFFFFFFFF,\"That player is not online\");
    if(strval(cmdtext[6])==playerid)return SendClientMessage(playerid,0xFFFFFFFF,\"You cannot invite yourself\");
   StartPong(playerid,strval(cmdtext[6]));
    ShowPlayerDialog(playerid,30000,DIALOG_STYLE_MSGBOX,\"Asking Permission...\",\"Asking player if he or she wants to play pong... 5 seconds remaining\",\"Cancel\",\"\");
    pDialog[playerid]=DIALOG_ASKING;
    pOpponent[strval(cmdtext[6])]=playerid;
    pOpponent[playerid]=strval(cmdtext[6]);
    ShowPlayerDialog(strval(cmdtext[6]),30000,DIALOG_STYLE_MSGBOX,\"Want to play pong?\",\"You have been asked to play pong, do you want to?\",\"Yes\",\"No\");
    pDialog[strval(cmdtext[6])]=DIALOG_BEINGASKED;
    SetTimerEx(\"UpdateDialog\",1000,0,\"ii\",playerid,4);
    }
    return 1;
}
if(!strcmp(cmdtext,\"/checkpong\",true))
{
    if(NewVersionAvailable)
    {
    new tmp[32];
    format(tmp,32,\"Release %d\",NewVersionAvailable);
    ShowPlayerDialog(playerid,30000,DIALOG_STYLE_MSGBOX,tmp,UpdateText,\"Close\",\"\");
    pDialog[playerid]=DIALOG_CHECKPONG;
    return 1;
    }
}
return 0;
}
new GlobalTemp[3];
public GameUpdate()
{
switch(BallPosition[0])
{
    //Left Wall
    case 0:
{
   BallVelocity[0]=random(5)+3;
   PlayerPlaySound(Players[0],1056,0,0,0);
   BallPosition[0]=200;
   GameScore[1]++;
   UpdateScore();
   CallLocalFunction(\"OnPlayerScore\",\"i\",1);
   if(!GameRunning)return;
}
    //Right Wall
    case 396:
{
   BallVelocity[0]=(-random(5))-3;
   PlayerPlaySound(Players[0],1056,0,0,0);
   BallPosition[0]=200;
   GameScore[0]++;
   UpdateScore();
   CallLocalFunction(\"OnPlayerScore\",\"i\",0);
   if(!GameRunning)return;
}
    //Left Paddle
    case 18:
    {
        if( (BallPosition[1]<=PaddlePositions[0]+40) && (BallPosition[1]>=PaddlePositions[0]-8) )
        {
      BallVelocity[0]=random(5)+3;
      BallVelocity[1]=(((BallPosition[1]-PaddlePositions[0])-22)/4)+2;
      PlayerPlaySound(Players[0],1056+SoundChange,0,0,0);
      PlayerPlaySound(Players[1],1056+SoundChange,0,0,0);
      if(SoundChange)SoundChange=0;
      else SoundChange=1;
        }
    }
    //Right Paddle
    case 377:
    {
        if( (BallPosition[1]<=PaddlePositions[1]+40) && (BallPosition[1]>=PaddlePositions[1]-8) )
        {
      BallVelocity[0]=(-random(5))-3;
      BallVelocity[1]=(((BallPosition[1]-PaddlePositions[1])-22)/4)+2;
      PlayerPlaySound(Players[0],1056+SoundChange,0,0,0);
      PlayerPlaySound(Players[1],1056+SoundChange,0,0,0);
      if(SoundChange)SoundChange=0;
      else SoundChange=1;
        }
}
}
//Roof
if(BallPosition[1]==0)
{
//BallVelocity[1]=random(5)+2;
BallVelocity[1]*=-1;
PlayerPlaySound(Players[0],1056+SoundChange,0,0,0);
PlayerPlaySound(Players[0],1056+SoundChange,0,0,0);
if(SoundChange)SoundChange=0;
else SoundChange=1;
}
//Floor
if(BallPosition[1]==240)
{
//BallVelocity[1]=(-random(5))-2;
BallVelocity[1]*=-1;
PlayerPlaySound(Players[0],1056+SoundChange,0,0,0);
PlayerPlaySound(Players[0],1056+SoundChange,0,0,0);
if(SoundChange)SoundChange=0;
else SoundChange=1;
}
if(BallVelocity[1]==0)BallVelocity[1]=2*(random(1)-1);
if(BallVelocity[0]==0)BallVelocity[0]=2*(random(1)-1);
//Player 1 Controls
if(Players[0]!=INVALID_PLAYER_ID)
{
GetPlayerKeys(Players[0],GlobalTemp[0],GlobalTemp[1],GlobalTemp[2]);
if(GlobalTemp[0]==KEY_SECONDARY_ATTACK)
{
   KillPong();
   new tmp[32];
   GetPlayerName(Players[0],tmp,32);
   format(tmp,32,\"%s quit\",tmp);
   SendClientMessage(Players[0],0xFFFFFFFF,tmp);
   SendClientMessage(Players[1],0xFFFFFFFF,tmp);
}
if(GlobalTemp[1]==KEY_UP)PaddlePositions[0]-=3;
else if(GlobalTemp[1]==KEY_DOWN)PaddlePositions[0]+=3;
}else{
    //NPC controls
    if(BallPosition[1]>PaddlePositions[0]+3)PaddlePositions[0]+=3;
    else PaddlePositions[0]-=3;
}
//Player 2 Controls
if(Players[1]!=INVALID_PLAYER_ID)
{
GetPlayerKeys(Players[1],GlobalTemp[0],GlobalTemp[1],GlobalTemp[2]);
if(GlobalTemp[0]==KEY_SECONDARY_ATTACK)
{
   KillPong();
   new tmp[32];
   GetPlayerName(Players[1],tmp,32);
   format(tmp,32,\"%s quit\",tmp);
   SendClientMessage(Players[0],0xFFFFFFFF,tmp);
   SendClientMessage(Players[1],0xFFFFFFFF,tmp);
}
if(GlobalTemp[1]==KEY_UP)PaddlePositions[1]-=3;
else if(GlobalTemp[1]==KEY_DOWN)PaddlePositions[1]+=3;
}else{
    //NPC controls
    if(BallPosition[1]>PaddlePositions[1]+3)PaddlePositions[1]+=3;
    else PaddlePositions[1]-=3;
}
//If ball is about to hit paddle\'s X coordinate, force it
if( ((BallPosition[0]-18)+BallVelocity[0]<0) && (BallPosition[0]>18) )BallPosition[0]=18;
else if( ((BallPosition[0]-377)+BallVelocity[0]>0) && (BallPosition[0]<377) )BallPosition[0]=377;
else BallPosition[0]+=BallVelocity[0];
//Adjust Balls Y coordinate
BallPosition[1]+=BallVelocity[1];
//Ball Limits
if(BallPosition[0]<0)BallPosition[0]=0;
if(BallPosition[0]>396)BallPosition[0]=396;
if(BallPosition[1]<0)BallPosition[1]=0;
if(BallPosition[1]>240)BallPosition[1]=240;
//Paddle Limits
if(PaddlePositions[0]>210)PaddlePositions[0]=210;
if(PaddlePositions[0]<0)PaddlePositions[0]=0;
if(PaddlePositions[1]>210)PaddlePositions[1]=210;
if(PaddlePositions[1]<0)PaddlePositions[1]=0;
//Update
PositionObjects();
}
 
//// OnPlayerScore callback
 
forward OnPlayerScore(player); //Player == 0 || 1 (1 and 2)
public OnPlayerScore(player)
{
if(GameScore[player]==15)   //Check to see if his score is high enough to win
{
if(Players[player]!=INVALID_PLAYER_ID)   //Affirm that winner is not an NPC
{
    SendClientMessage(Players[player],0xFFFFFFFF,\"You win! {00FF00}+$15\");  //Winning message
    GivePlayerMoney(Players[player],15);
}
new loser;
if(player)loser=0;  //Get losing player
else loser=1;
if(Players[loser]!=INVALID_PLAYER_ID)   //Make sure loser is not an NPC
{
    SendClientMessage(Players[loser],0xFFFFFFFF,\"You lose! {FF0000}-$15\"); //Losing message
    GivePlayerMoney(Players[loser],-15);
}
KillPong();   //Be sure to kill the game
}
}
public CheckUpdate(index, response_code, data[])
{
if(response_code==200)
{
format(UpdateText,512,\"%s\",data[strfind(data,\",\")+1]);
new tmp[11];
strmid(tmp,data,0,strfind(data,\",\"));
if(strval(tmp)>Release)
{
   NewVersionAvailable=strval(tmp);
        print(\"A new version of Joe Staff\'s \\\"Pong\\\" is available, type \\\"/CheckPong\\\" for more info\");
        printf(\"%s\",UpdateText);
}
}
}
public OnPlayerConnect(playerid)
{
if(NewVersionAvailable)SendClientMessage(playerid,0xFFFFFFFF,\"A new version of Joe Staff\'s \\\"Pong\\\" is available, type \\\"/CheckPong\\\" for more info\");
}
public UpdateDialog(playerid,time)
{
if(GameRunning)
{
    for(new i;i<MAX_PLAYERS;i++)
    {
        if( (pDialog==DIALOG_ASKING) || (pDialog==DIALOG_BEINGASKED) )
        {
            ShowPlayerDialog(i,-1,-1,\"\",\"\",\"\",\"\");
            SendClientMessage(i,0xFFFFFFFF,\"A game has started and you cannot play\");
        }
    }
    return;
}
if(time==0)
{
pDialog[playerid]=DIALOG_NONE;
pDialog[pOpponent[playerid]]=DIALOG_NONE;
    ShowPlayerDialog(playerid,-1,-1,\"\",\"\",\"\",\"\");
    ShowPlayerDialog(pOpponent[playerid],-1,-1,\"\",\"\",\"\",\"\");
    pOpponent[pOpponent[playerid]]=INVALID_PLAYER_ID;
    pOpponent[playerid]=INVALID_PLAYER_ID;
    return;
}
if(pOpponent[playerid]==INVALID_PLAYER_ID)return;
new tmp[64];
format(tmp,64,\"Asking player if he or she wants to play pong... %d seconds remaining\",time);
ShowPlayerDialog(playerid,30000,DIALOG_STYLE_MSGBOX,\"Asking Permission...\",tmp,\"Cancel\",\"\");
SetTimerEx(\"UpdateDialog\",1000,0,\"ii\",playerid,time-1);
}
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
if(dialogid!=30000)return 1;
switch(pDialog[playerid])
{
    case DIALOG_NONE:return 1;
    case DIALOG_CHECKPONG:
    {
        pDialog[playerid]=DIALOG_NONE;
        return 1;
    }
    case DIALOG_ASKING:
    {
        ShowPlayerDialog(pOpponent[playerid],-1,-1,\"\",\"\",\"\",\"\");
        pDialog[playerid]=DIALOG_NONE;
        pDialog[pOpponent[playerid]]=DIALOG_NONE;
        SendClientMessage(playerid,0xFFFFFFFF,\"You backed down your offer\");
        SendClientMessage(pOpponent[playerid],0xFFFFFFFF,\"The offer was backed down\");
        pOpponent[pOpponent[playerid]]=INVALID_PLAYER_ID;
        pOpponent[playerid]=INVALID_PLAYER_ID;
        return 1;
    }
    case DIALOG_BEINGASKED:
    {
        if(!response)
        {
        ShowPlayerDialog(pOpponent[playerid],-1,-1,\"\",\"\",\"\",\"\");
        pDialog[playerid]=DIALOG_NONE;
        pDialog[pOpponent[playerid]]=DIALOG_NONE;
        SendClientMessage(playerid,0xFFFFFFFF,\"You declined the offer\");
        SendClientMessage(pOpponent[playerid],0xFFFFFFFF,\"The offer was declined\");
        pOpponent[pOpponent[playerid]]=INVALID_PLAYER_ID;
        pOpponent[playerid]=INVALID_PLAYER_ID;
        return 1;
        }
        StartPong(playerid,pOpponent[playerid]);
    pDialog[playerid]=DIALOG_NONE;
    pDialog[pOpponent[playerid]]=DIALOG_NONE;
        pOpponent[pOpponent[playerid]]=INVALID_PLAYER_ID;
        pOpponent[playerid]=INVALID_PLAYER_ID;
    }
}
return 1;
}

 
Eredeti szerzõje ennek a FS-nek Joe Staff.Kösz hogy megnézted csõ.

Nem elérhető gyuri98

  • 153
  • gyuri98
    • Profil megtekintése
PING PONG vagyis PONG
« Válasz #1 Dátum: 2013. június 29. - 13:03:09 »
0 Show voters
Sok értelme nincs.....am a szerzõt teheted volna feltûnõbb helyre is.

PING PONG vagyis PONG
« Válasz #2 Dátum: 2013. június 29. - 14:47:46 »
0 Show voters
El lehet vele szórakozni, de nagyon nincs értelme ahogy mondták. :D


Ezt szerintem a \"Hivatalos fórumról áthozott szkriptek\"-hez, kellet volna meg nyitni.

Nem elérhető CANNONN

  • 2139
    • Profil megtekintése
PING PONG vagyis PONG
« Válasz #3 Dátum: 2013. június 29. - 16:34:46 »
0 Show voters
[mod]Kedves téma nyitó!
Egy új alfórum jött létre ( Hivatalos fórumról áthozott szkriptek ) Melyben csak magyarra fordított scripteket tehettek közzé. És megkérnélek hogy fordítsd le.
Vagy ha nem akarod kérd a téma törlését. Szabályzatot ide kattintva tekintheted meg.
További jó fórumozást![/mod]

 

SimplePortal 2.3.7 © 2008-2024, SimplePortal