GTA Közösség - A magyar GTA fórum

San Andreas Multiplayer (SA-MP) => SA-MP: Szerverfejlesztés => Segítségkérés => A témát indította: Nátha - 2012. október 05. - 14:03:17

Cím: Dialog
Írta: Nátha - 2012. október 05. - 14:03:17
Üdv
Van Srjdan-nek a hõlégballon scriptje, és az /operate parancsot dialoggal szeretném megoldani csak nem sikerül. Egyszerûen úgy kellene hogy beírja /operate felhoz egy MSGBOX stílusú dialogot Melyben ezt írná: Itt vehetsz jegyet a hõlégballonhoz. és lenne két gombja hogy Veszek Nem veszek. Ha Veszekre megy akk behozza az irányítási menüt meg mindent ha nem veszekre akk csak kilép a dialogból.
Script:
 
// Hot air balloon filterscript by Srdjan
// Date is 01/11/2011
#include <a_samp>
#include <mapandreas>
#define KEY_AIM 128
#define MAX_BALLOONS 10
new BalloonID[MAX_BALLOONS];
new PlayerInBalloon[MAX_PLAYERS];
new Float: BalloonSpeed[MAX_BALLOONS];
new Float: Radius[MAX_BALLOONS];
new Float: Diametar[MAX_BALLOONS];
new ResetTimer[MAX_BALLOONS];
new ContinueTimer[MAX_BALLOONS];
new Text:commands;
forward ResetSpeed (objectid);
forward Continue (objectid);
public OnFilterScriptInit ()
{
CreateBalloons ();
commands = TextDrawCreate (30.0, 270.0,\"~w~Parancsok:~n~Space - fel~n~Bal shift - le~n~Y - Lefele dontes~n~N - Felfele dontes~n~Bal klikk - Balra menes~n~Jobb klikk - Jobbra menes\");
TextDrawFont (commands, 2);
TextDrawLetterSize (commands, 0.3, 0.8);
MapAndreas_Init (MAP_ANDREAS_MODE_FULL);
for (new i = 0; i < MAX_PLAYERS; i++) PlayerInBalloon = -1;
printf (\"\\nHot Air Balloon by Srdjan loaded.\\n\");
return 1;
}
CreateBalloons ()
{
BalloonID[0] = CreateObject (19334, 198.9927, -1832.8091, 3.0, 0.0, 0.0, 0.0, 300.0);
BalloonID[1] = CreateObject (19335, 241.3257, -1834.1189, 3.0, 0.0, 0.0, 0.0, 300.0);
BalloonID[2] = CreateObject (19336, 284.8625, -1830.8752, 3.0, 0.0, 0.0, 0.0, 300.0);
for (new i = 0; i < 3; i++)
{
new id = CreateObject (18699, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 300.0);
AttachObjectToObject (id, BalloonID, 0.0, 0.0, 5.5, 0.0, 180.0, 0.0, 1);
}
}
public OnPlayerCommandText (playerid, cmdtext[])
{
if (!strcmp (cmdtext, \"/operate\"))
{
if (PlayerInBalloon[playerid] != -1)
{
ClearAnimations (playerid);
TextDrawHideForPlayer (playerid, commands);
PlayerInBalloon[playerid] = -1;
}
else
{
if (GetPlayerBalloonID (playerid, 0) > -1)
{
ApplyAnimation (playerid, \"GANGS\", \"leanIDLE\", 4.1, 1, 1, 1, 1, 0, 1);
TextDrawShowForPlayer (playerid, commands);
PlayerInBalloon[playerid] = GetPlayerBalloonID (playerid, 0);
}
else if (GetPlayerBalloonID (playerid, 1) > -1)
{
new objectid = BalloonID[GetPlayerBalloonID (playerid, 1)];
if (IsObjectMoving (objectid))
{
ApplyAnimation (playerid, \"GANGS\", \"leanIDLE\", 4.1, 1, 1, 1, 1, 0, 1);
TextDrawShowForPlayer (playerid, commands);
PlayerInBalloon[playerid] = GetPlayerBalloonID (playerid, 1);
}
}
}
return 1;
}
return 0;
}
GetPlayerBalloonID (playerid, b)
{
new Float: x, Float: y, Float: z;
for (new i = 0; i < sizeof (BalloonID); i++)
{
GetObjectPos (BalloonID, x, y, z);
if (!b)
{
if (!IsPlayerInRangeOfPoint (playerid, 1.5, x, y, z)) continue;
else return i;
}
else if (b)
{
if (!IsPlayerInRangeOfPoint (playerid, 5.0, x, y, z)) continue;
else return i;
}
}
return -1;
}
public OnPlayerKeyStateChange (playerid, newkeys, oldkeys)
{
if (PlayerInBalloon[playerid] > -1)
{
new objectid = BalloonID[PlayerInBalloon[playerid]];
if ((newkeys & KEY_SPRINT) && !(oldkeys & KEY_SPRINT))
{
if (BalloonSpeed[objectid] < 15.0) BalloonSpeed[objectid] += 0.5;
}
if ((newkeys & KEY_JUMP) && !(oldkeys & KEY_JUMP))
{
if (BalloonSpeed[objectid] > -10.0) BalloonSpeed[objectid] -= 0.5;
}
if ((newkeys & KEY_YES) && !(oldkeys & KEY_YES))
{
if (Radius[objectid] < 90.0) Radius[objectid] += 5.0;
}
if ((newkeys & KEY_NO) && !(oldkeys & KEY_NO))
{
if (Radius[objectid] > 0.0) Radius[objectid] -= 5.0;
}
if ((newkeys & KEY_FIRE) && !(oldkeys & KEY_FIRE))
{
Diametar[objectid] -= 5.0;
if (Diametar[objectid] < 0.0) Diametar[objectid] = -5.0;
}
if ((newkeys & KEY_AIM) && !(oldkeys & KEY_AIM))
{
Diametar[objectid] += 5.0;
if (Diametar[objectid] > 360.0) Diametar[objectid] = 5.0;
}
UpdateBalloonMove (objectid);
}
return 1;
}
UpdateBalloonMove (objectid)
{
StopObject (objectid);
if (BalloonSpeed[objectid] > 0.0)
{
Continue (objectid);
}
else if (BalloonSpeed[objectid] < 0.0)
{
KillTimer (ResetTimer[objectid]);
new Float: x, Float: y, Float: z;
GetObjectPos (objectid, x, y, z);
MapAndreas_FindZ_For2DCoord (x, y, z);
new time = MoveObject (objectid, x, y, z, floatabs(BalloonSpeed[objectid]));
ResetTimer[objectid] = SetTimerEx (\"ResetSpeed\", time, 0, \"d\", objectid);
}
}
public ResetSpeed (objectid)
{
if (BalloonSpeed[objectid] < 0.0) BalloonSpeed[objectid] = 0.0;
if (Radius[objectid] > 0.0) Radius[objectid] = 0.0;
}
public Continue (objectid)
{
new Float: x, Float: y, Float: z;
GetObjectPos (objectid, x, y, z);
KillTimer (ResetTimer[objectid]);
KillTimer (ContinueTimer[objectid]);
z = z + 300 * floatcos (-Radius[objectid], degrees);
x = x + 1000 * floatsin (-Radius[objectid], degrees) * floatcos (-Diametar[objectid], degrees);
y = y + 1000 * floatsin (-Radius[objectid], degrees) * floatsin (-Diametar[objectid], degrees);
new time = MoveObject (objectid, x, y, z, BalloonSpeed[objectid]);
ContinueTimer[objectid] = SetTimerEx (\"Continue\", time-2, 0, \"d\", objectid);
}

 
Elõre is köszönöm
Cím: Dialog
Írta: ZyZu. - 2012. október 05. - 14:08:44
Ezt nézd meg majd olvasd el és a többit az OnPlayerDialogResponse alá beírod és menni fog neked :)
http://wiki.sa-mp.com/wiki/OnDialogResponse
Cím: Dialog
Írta: Nátha - 2012. október 05. - 14:40:23
Épp ez az hogy nem megy, kidobott vagy 26 errort  :D
Cím: Dialog
Írta: RolePlay - 2012. október 05. - 14:46:14

#include <a_samp>
#include <zcmd>
#define BALLON 1
CMD:operate(playerid, params[])
{
ShowPlayerDialog(playerid, BALLON+1, DIALOG_STYLE_MSGBOX, \"Jegy árus\", \"Egy jegy 100$, megveszed?\", \"Tovább\", \"Kilépés\");
    return 1;
}
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
if(dialogid == BALLON)
    {
       if(response)
        {
           if(listitem == 0)
            {
               ShowPlayerDialog(playerid, BALLON+1, DIALOG_STYLE_MSGBOX, \"Jegy árus\", \"Egy jegy 100$, megveszed?\", \"Megveszem\", \"Kössz nem\");
   }
}
}
if(dialogid == BALLON+1)
    {
       if(response)
        {
            SendClientMessage(playerid, -1, \"Megvásároltad a jegyet!\");
            GivePlayerMoney(playerid, -100);
            // Itt beállítod amit szeretnél, hogy irányítson.
 }
else
if(!response)
{
   SendClientMessage(playerid, -1, \"Jegyvásárlás megszakítva.\");
   }
}
return 1;
}

 
A többi részt neked kell beépíteni :)
Cím: Dialog
Írta: ZyZu. - 2012. október 05. - 15:18:14
Ami a parancs alatt van azt ide bemásolod:
 

public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
        if(dialogid == BALLON)
    {
        if(response)
        {
                if(listitem == 0)
            {
                ShowPlayerDialog(playerid, BALLON+1, DIALOG_STYLE_MSGBOX, \"Jegy árus\", \"Egy jegy 100$, megveszed?\", \"Megveszem\", \"Kössz nem\");
                        }
                }
        }
        if(dialogid == BALLON+1)
    {
        if(response)
        {
            SendClientMessage(playerid, -1, \"Megvásároltad a jegyet!\");
            GivePlayerMoney(playerid, -100);
            // Itt beállítod amit szeretnél, hogy irányítson.
                 }
                else
                if(!response)
                {
                        SendClientMessage(playerid, -1, \"Jegyvásárlás megszakítva.\");
                }
        }
        return 1;
}
Cím: Dialog
Írta: RolePlay - 2012. október 05. - 15:32:57
Zyzu, te tényleg ilyen paraszt vagy ? :DDD
// jel után beírja amire szüksége van, ha már ott jeleztem neki.
Szerintem nem hülye, veled ellentétbe... 37 sort képtelen vagy neki össze tenni, de ha vki megcsinálta utána osztod az észt. idióta.
Cím: Dialog
Írta: Nátha - 2012. október 05. - 16:13:23
Nos a dialoggal eddig sem volt nagy problémám, inkább a scriptbe írásával. Abba tudnál még segíteni ?