SA-MP Forums Archive
Major scripting help - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Major scripting help (/showthread.php?tid=326074)



Major scripting help - vvhy - 16.03.2012

Thanks for your help.


Re: Major scripting help - Shabi RoxX - 16.03.2012

You Missed samp callbacks like:

pawn Код:
//define menu first
new Menu:teleportmenu;//defines a new menu name/id

//forwad your function
forward IsPlayerInArea();//must forward a function

OnGameModeInit()//add other things goes here like vehicles,objects and also menu :)

OnPlayerSelectedMenuRow(playerid, row)//use for any menu action
So that cause your Pawno to crash:

Try this:
pawn Код:
// By Shabi RoxX

#include <a_samp>

//define menu first
new Menu:teleportmenu;

//forwad your function
forward IsPlayerInArea();

main()
{
    print("\n----------------------------------");
    print("            LOL                     ");
    print("----------------------------------\n");
}




public OnGameModeInit()
{
    // you must create menu in OnGameModeInit
    teleportmenu = CreateMenu("Elevator Menu", 1, 200.0, 300.0, 300.0, 0.0);
    AddMenuItem(teleportmenu, 0, "Ground Floor");
    AddMenuItem(teleportmenu, 0, "First Floor");
    AddMenuItem(teleportmenu, 0, "Second Floor");
    AddMenuItem(teleportmenu, 0, "Third Floor");
    AddMenuItem(teleportmenu, 0, "Fourth Floor");
    AddMenuItem(teleportmenu, 0, "Fith Floor");
    AddMenuItem(teleportmenu, 0, "Sixth Floor");
    AddMenuItem(teleportmenu, 0, "Seventh Floor");
    AddMenuItem(teleportmenu, 0, "Eighth Floor");
    AddMenuItem(teleportmenu, 0, "Ninth Floor");
    AddMenuItem(teleportmenu, 0, "Tenth Floor");
    AddMenuItem(teleportmenu, 0, "Eleventh Floor");
    AddMenuItem(teleportmenu, 0, "Twelfth Floor");
    AddMenuItem(teleportmenu, 0, "Thirteenth Floor");
    AddMenuItem(teleportmenu, 0, "Fourteenth Floor");
    AddMenuItem(teleportmenu, 0, "Fifteenth Floor");
    AddMenuItem(teleportmenu, 0, "Sixteenth Floor");
    AddMenuItem(teleportmenu, 0, "Seventeenth Floor");
    AddMenuItem(teleportmenu, 0, "Eighteenth Floor");
    AddMenuItem(teleportmenu, 0, "Nineteenth Floor");
    AddMenuItem(teleportmenu, 0, "Penthouse");
   
    SetTimer("IsPlayerInArea", 1000, true);//will repeat every 1 second to check if any player on pos :)
   
    SetGameModeText("Shabi Test");
    AddPlayerClass(0, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);
    return 1;
}

public IsPlayerInArea()
{
    new Float:X, Float:Y, Float:Z;
    for(new i=0; i < MAX_PLAYERS; i++)
    {
        GetPlayerPos(i, X, Y, Z);
        if(IsPlayerConnected(i))//checking if player is connected else nothing
        {
            if (X <= -1915.6198 && X >= -1917.0597 && Y <= 1114.1592 && Y >=  1111.3760)
            {
                ShowMenuForPlayer(teleportmenu,i);//don't use playerid , use i as it will define player whose of that pos
                return 1;
            }
        }
    }
    return 1;
}

public OnGameModeExit()
{
    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;
}

public OnPlayerConnect(playerid)
{
    return 1;
}

public OnPlayerDisconnect(playerid, reason)
{
    return 1;
}

public OnPlayerSpawn(playerid)
{
    return 1;
}

public OnPlayerDeath(playerid, killerid, reason)
{
    return 1;
}

public OnVehicleSpawn(vehicleid)
{
    return 1;
}

public OnVehicleDeath(vehicleid, killerid)
{
    return 1;
}

public OnPlayerText(playerid, text[])
{
    return 1;
}

public OnPlayerCommandText(playerid, cmdtext[])
{
    if (strcmp("/mycommand", cmdtext, true, 10) == 0)
    {
        // Do something here
        return 1;
    }
    return 0;
}

public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
    return 1;
}

public OnPlayerExitVehicle(playerid, vehicleid)
{
    return 1;
}

public OnPlayerStateChange(playerid, newstate, oldstate)
{
    return 1;
}

public OnPlayerEnterCheckpoint(playerid)
{
    return 1;
}

public OnPlayerLeaveCheckpoint(playerid)
{
    return 1;
}

public OnPlayerEnterRaceCheckpoint(playerid)
{
    return 1;
}

public OnPlayerLeaveRaceCheckpoint(playerid)
{
    return 1;
}

public OnRconCommand(cmd[])
{
    return 1;
}

public OnPlayerRequestSpawn(playerid)
{
    return 1;
}

public OnObjectMoved(objectid)
{
    return 1;
}

public OnPlayerObjectMoved(playerid, objectid)
{
    return 1;
}

public OnPlayerPickUpPickup(playerid, pickupid)
{
    return 1;
}

public OnVehicleMod(playerid, vehicleid, componentid)
{
    return 1;
}

public OnVehiclePaintjob(playerid, vehicleid, paintjobid)
{
    return 1;
}

public OnVehicleRespray(playerid, vehicleid, color1, color2)
{
    return 1;
}

public OnPlayerSelectedMenuRow(playerid, row)
{
    new Menu:CurrentMenu = GetPlayerMenu(playerid);
    if(CurrentMenu == teleportmenu)
    {
        switch(row)
        {
            case 0:
            {SetPlayerPos(playerid,-1916.9716,1112.4375,48.7100);}
            case 1: //Ground
            {SetPlayerPos(playerid,-1916.9716,1112.4375,48.7100+ 8.7396 + (1 * 5.45155));}
            case 2: //First
            {SetPlayerPos(playerid, -1916.9716,1112.4375,48.7100+ 8.7396 + (2 * 5.45155));}
            case 3: //Second
            {SetPlayerPos(playerid,-1916.9716,1112.4375,48.7100+ 8.7396 + (3 * 5.45155));}
            case 4: //Third
            {SetPlayerPos(playerid,-1916.9716,1112.4375,48.7100+ 8.7396 + (4 * 5.45155) );}
            case 5: //Fourth
            {SetPlayerPos(playerid,-1916.9716,1112.4375,48.7100+ 8.7396 + (5 * 5.45155));}
            case 6: //Fifth
            {SetPlayerPos(playerid,-1916.9716,1112.4375,48.7100+ 8.7396 + (6 * 5.45155));}
            case 7: //Sixth
            {SetPlayerPos(playerid,-1916.9716,1112.4375,48.7100+ 8.7396 + (7 * 5.45155));}
            case 8: //Seventh
            {SetPlayerPos(playerid,-1916.9716,1112.4375,48.7100+ 8.7396 + (8 * 5.45155));}
            case 9: //Eighth
            {SetPlayerPos(playerid,-1916.9716,1112.4375,48.7100+ 8.7396 + (9 * 5.45155));}
            case 10: //Ninth
            {SetPlayerPos(playerid,-1916.9716,1112.4375,48.7100+ 8.7396 + (10 * 5.45155));}
            case 11: //Tenth
            {SetPlayerPos(playerid,-1916.9716,1112.4375,48.7100+ 8.7396 + (11 * 5.45155));}
            case 12: //Eleventh
            {SetPlayerPos(playerid,-1916.9716,1112.4375,48.7100+ 8.7396 + (12 * 5.45155));}
            case 13: //Twelth
            {SetPlayerPos(playerid,-1916.9716,1112.4375,48.7100+ 8.7396 + (13 * 5.45155));}
            case 14: //Thirteenth
            {SetPlayerPos(playerid,-1916.9716,1112.4375,48.7100+ 8.7396 + (14 * 5.45155));}
            case 15: //Fourteenth
            {SetPlayerPos(playerid,-1916.9716,1112.4375,48.7100+ 8.7396 + (15 * 5.45155));}
            case 16: //Fifteenth
            {SetPlayerPos(playerid,-1916.9716,1112.4375,48.7100+ 8.7396 + (16 * 5.45155));}
            case 17: //Sixteenth
            {SetPlayerPos(playerid,-1916.9716,1112.4375,48.7100+ 8.7396 + (17 * 5.45155));}
            case 18: //Seventeenth
            {SetPlayerPos(playerid,-1916.9716,1112.4375,48.7100+ 8.7396 + (18 * 5.45155));}
            case 19: //Eighteenth
            {SetPlayerPos(playerid,-1916.9716,1112.4375,48.7100+ 8.7396 + (19 * 5.45155));}
            case 20: //Nineteenth
            {SetPlayerPos(playerid,-1916.9716,1112.4375,48.7100+ 8.7396 + (20 * 5.45155));}
                        //Penthouse
        }
    }
    return 1;
}

public OnPlayerExitedMenu(playerid)
{
    return 1;
}

public OnPlayerInteriorChange(playerid, newinteriorid, oldinteriorid)
{
    return 1;
}

public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
    return 1;
}

public OnRconLoginAttempt(ip[], password[], success)
{
    return 1;
}

public OnPlayerUpdate(playerid)
{
    return 1;
}

public OnPlayerStreamIn(playerid, forplayerid)
{
    return 1;
}

public OnPlayerStreamOut(playerid, forplayerid)
{
    return 1;
}

public OnVehicleStreamIn(vehicleid, forplayerid)
{
    return 1;
}

public OnVehicleStreamOut(vehicleid, forplayerid)
{
    return 1;
}

public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
    return 1;
}

public OnPlayerClickPlayer(playerid, clickedplayerid, source)
{
    return 1;
}



Re: Major scripting help - vvhy - 16.03.2012

Код:
#Γδ←δδ         {Д9