New to Pawn, need a lil help
#1

Hey all, So. as the title reads, i am new to pawn scripting for SA:MP and need a lil help. I am trying to make a script to be able to make a menu called "teleports", and have 2 or more items inside the menu. (1 to cars, and 1 to boats). I finished writing the script, tried to compile it, and the program froze. I dont know if it has anything to do with my code, or my computer. plz help, il pst my code below.

Код:
new Menu:teleportmenu;
teleportmenu = CreateMenu("Teleportmenu", 2, 200.0, 100.0, 150.0, 150.0);
	AddMenuItem(teleportmenu, 0, "Cars");
	AddMenuItem(teleportmenu, 0, "Boats");
new Menu:CurrentMenu = GetPlayerMenu(playerid);
if (CurrentMenu == teleportmenu)
{
	switch(row)
	{
	  case 0: //Cars
	  {
	  	SetPlayerPos(playerid, 2008.595, -2382.287, 13.3382);
	  	SetPlayerInterior(playerid, 0);
	  	SendClientMessage(playerid, 0xFFFFFFFF, "Welcome to the Car Lot");
		}
		case 1: //Boats
		{
		  SetPlayerPos(playerid, 467.115, -2534.099, 13.3382);
		  SetPlayerInterior(playerid, 0);
		  SendClientMessage(playerid, 0xFFFFFFFF, "Welcome to the Boat lot"
		}
	}
}
if(strcmp(cmdtext, "/teleport", true) == 0)
{
	ShowMenuForPlayer(teleportmenu,playerid);
	return 1;
}
Any help will be appreciated, much thanks.
Reply
#2

new Menu:teleportmenu; << This should go above OnGameModeInit.

teleportmenu = createmenu... this should go below the OnGameModeInit,

If(currentmenu.... << This should go BELOW OnPlayerSelectedMenuRow

if(strcmp(cmdtext,"/telport... << this should go below onplayercommandtext
Reply
#3

Uhmmm... Next time please use
or or put it in http://pastebin.com
before you post any code It's very hard to read
________
CANCER - LUNG FORUMS
Reply
#4

Quote:
Originally Posted by 0ne
new Menu:teleportmenu; << This should go above OnGameModeInit.

teleportmenu = createmenu... this should go below the OnGameModeInit,

If(currentmenu.... << This should go BELOW OnPlayerSelectedMenuRow

if(strcmp(cmdtext,"/telport... << this should go below onplayercommandtext
I made those changes. but, Pawno compile still freezes, it puts 2 files on my desktop (teleports1.pwn, teleports1.amx) i dont know if those are what i need. I put both of those files in my filterscripts folder, and added "teleports1" to my server file, and when i run my server it starts up, and shuts down almost immidatly. i looked in the server_log file, and it said
Quote:

[14:58:42]
[14:58:42] Server Plugins
[14:58:42] --------------
[14:58:42] Loaded 0 plugins.

[14:58:42]
[14:58:42] Filter Scripts
[14:58:42] ---------------
[14:58:42] Loading filter script 'base.amx'...
[14:58:42]
--Base FS loaded.

[14:58:42] Loading filter script 'gl_actions.amx'...
[14:58:42] Loading filter script 'gl_property.amx'...
[14:58:42]
-----------------------------------
[14:58:42] Grand Larceny Property Filterscript
[14:58:42] -----------------------------------

[14:58:42] Loading filter script 'gl_realtime.amx'...
[14:58:42] Loading filter script 's&r.amx'...
[14:58:42] Loading filter script 'R_Speedov2.amx'...
[14:58:42]
--------------------------------------
[14:58:42] Speedometer by [WsR]RyDeR - Loaded -
[14:58:42] --------------------------------------

[14:58:42] Loading filter script 'teleports1.amx'...
[14:58:42] Failed to load 'filterscripts/teleports1.amx.amx' filter script.
[14:58:42] Unable to load filter script 'teleports1.amx'.
[14:58:42] Loaded 6 filter scripts.

Any ideas why its not working? As i said earler, i am verry verry new to pawno scripting (this will be my first script, so that probably explains why it has many issues. lol)
Reply
#5

pawn Код:
new Menu:teleportmenu; // This creates a Menu with name of :teleportmenu

public OnGameModeInit();
{ // Start bracket.
teleportmenu = CreateMenu("Teleportmenu", 2, 200.0, 100.0, 150.0, 150.0); // teleportmenu = << here we put in the name of menu which we created above and do CreateMenu(functions....)
AddMenuItem(teleportmenu, 0, "Cars"); // This adds a ITEM to the specific menu, ex: AddMenuItem(MenuName, column,String.);
AddMenuItem(teleportmenu, 0, "Boats"); //same as above
return 1; // Return a 1, mostly every command returns a 1.(i don't know how to explain this to you but i know when to put in a 0 or something myself (lol))
} // Ending bracket, we put } which is ending bracket because there is a start bracket which i marked above
public OnPlayerSelectedMenuRow(playerid, row)
{ // Startbracket
new Menu:CurrentMenu = GetPlayerMenu(playerid);
if (CurrentMenu == teleportmenu)
{// 2nd bracket
    switch(row)
    {//3rd bracket
      case 0: //Cars //A menu Always begins with case 0: and has a opening bracket. which is in this case below case 0,the //4th bracket
      {//4th bracket
        SetPlayerPos(playerid, >>> HERE ]2008.595, -2382.287, 13.3382 << HERE); //Set's the player position to the specific X,Y,Z Float coordinates.
        SetPlayerInterior(playerid, 0); // Set's player interior, in this case its 0, SetPlayerInterior(playerid,0);
        SendClientMessage(playerid, 0xFFFFFFFF, "[MESSAGE IS HERE >> Welcome to the Car Lot"); // Send the client message;
        }//4th bracket closes(if u didn't get if the code is intended you should see that brackets are equal, ex:
  { // Opening bracket
  | // Just to show that they're line is equal so you can see which opened bracket closes somewhere by following it.
  |
  |
  |
  } // Closing bracket

        case 1: //Boats
        {
          SetPlayerPos(playerid, 467.115, -2534.099, 13.3382);
          SetPlayerInterior(playerid, 0);
          SendClientMessage(playerid, 0xFFFFFFFF, "Welcome to the Boat lot"
        }
    }
}
public OnPlayerCommandText(playerid, cmdtext[])
{
if(strcmp(cmdtext, "/teleport", true) == 0) // this creates a command
{ // again starting bracket
|   ShowMenuForPlayer([b]teleportmenu[/b],playerid); //show's the specific menu for player( MENU WHICH TO SHOW IS BOLD)
|   return 1;
}// endingbracket of command
return 0; //Cmdtext end with a return 0 if it is a unknown command, you can change it i guess to: Return SendClientMessage(playerid,COLOR,string); which shows a msg if it's unknown command in your style.
} // ending bracket of opened commandtext
You should understand something more now, when you compile you get the .AMX file if there is no errors while compiling, the errors always shows a line ex:

E:\Games Setup\Gta san andreas server\Install\samp02Xserver.win32\gamemodes\FreeR oam.pwn(7360) : warning 204: symbol is assigned a value that is never used: "MiniMissionTimer"

the line is shown in bold : 7360 , we got a warning there but thats from my server nevermind it just showed u how it goes.

the .pwn file is the source where you write your code and edit or add something more
the .amx file is source compiled file.

The compiler freezes mostly when you miss a ENDING or a STARTING bracket }, {, if you want to load a filterscript, add the .AMX in the FILterscripts folder and in the SERVER.CFG file where it's filterscript line add it , like:

filterscript teleports1
if you want to add some more do like this:

filterscripts teleport1 teleport2 headshot

and so on..

edit: download a filterscript and a gamemode see their source code, if you know english pretty well you will understand half of the commands and the combinations, clicking on a Command which is shown to the right in the list will show below what functions you need to put in, while writing the command ex:

SendClientMessage(
hold SHIFT when u stop writing on the ( and it will show you the functions to put in

By the way, you're gamemode shuts down maybe because you didn't put a gamemode in your server.cfg if you want to run a server you "ALWAYS" need to put a gamemode to launch the server ex:

gamemode 0 lvdm
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)