Some Problems
#1

Hi Everybody!
I'm new in this forum and i'm not english so forgive my speaking...

I have some problems with my own SA-MP server. I will make a list of problems with the scripting.

1) I want remove the text that appears when i go near a house or a business. It's "House: Type /enter to enter.". I searched in pawno this text but it doesn't exist!!

2) I want that i have to press the enter key to enter into a business or in a house! I tried with:
Код:
public OnPlayerKeyStateChange (playerid, newkeys)

if(newkeys == KEY_SECONDARY_ATTACK)
{
my enter script
}
but it says to me that "newkeys" is an undefined symbol.

My enter script is:
Код:
if(strcmp(cmd, "/entra", true) == 0)
	{
		for(new i = 0; i < sizeof(Houses); i++)
		{
				if (PlayerToPoint(1.0, playerid,Houses[i][EnterX], Houses[i][EnterY], Houses[i][EnterZ]))
				{
				//if(GetPlayerVirtualWorld(playerid) == Houses[i][EnterWorld])
			    //{
					if(PlayerInfo[playerid][pHouseKey] == i || Houses[i][Locked] == 0 || PlayerInfo[playerid][pAdmin] >= 1)
					{
                        PlayerActionMessage(playerid,15.0,"Open door and enter.");
						SetPlayerInterior(playerid,Houses[i][ExitInterior]);
						SetPlayerPos(playerid,Houses[i][ExitX],Houses[i][ExitY],Houses[i][ExitZ]);
						SetPlayerVirtualWorld(playerid,i);
						SetPlayerFacingAngle(playerid,Houses[i][ExitAngle]);
					}
 					else
					{
						GameTextForPlayer(playerid, "~r~Closed", 5000, 1);
					}
				//}
			}
		}
		for(new i = 0; i < sizeof(Building); i++)
		{
			if (PlayerToPoint(1.0, playerid,Building[i][EnterX], Building[i][EnterY], Building[i][EnterZ]))
			{
			    if(GetPlayerVirtualWorld(playerid) == Building[i][EnterWorld])
			    {
					if(Building[i][Locked] == 0 || PlayerInfo[playerid][pAdmin] >=  1)
					{
					    if(GetPlayerCash(playerid) >= Building[i][EntranceFee])
					    {
					        PlayerActionMessage(playerid,15.0,"apre la porta ed entra.");
							SetPlayerInterior(playerid,Building[i][ExitInterior]);
							SetPlayerVirtualWorld(playerid,i);
							SetPlayerPos(playerid,Building[i][ExitX],Building[i][ExitY],Building[i][ExitZ]);
							SetPlayerFacingAngle(playerid,Building[i][ExitAngle]);
							GivePlayerCash(playerid,-Building[i][EntranceFee]);
						}
						else
						{
						    PlayerActionMessage(playerid,15.0,"open door and enter.");
							SetPlayerInterior(playerid,Building[i][ExitInterior]);
							SetPlayerVirtualWorld(playerid,i);
							SetPlayerPos(playerid,Building[i][ExitX],Building[i][ExitY],Building[i][ExitZ]);
							SetPlayerFacingAngle(playerid,Building[i][ExitAngle]);
						}
					}
					else
					{
					GameTextForPlayer(playerid, "~r~Closed", 5000, 1);
					}
				}
			}
		}
		for(new i = 0; i < sizeof(Businesses); i++)
			{
				if (PlayerToPoint(1.0, playerid,Businesses[i][EnterX], Businesses[i][EnterY], Businesses[i][EnterZ]))
				{
				 	if(GetPlayerVirtualWorld(playerid) == Businesses[i][EnterWorld])
				    {
						if(PlayerInfo[playerid][pBizKey] == i || GetPlayerCash(playerid) >= Businesses[i][EntranceCost])
						{
							if(PlayerInfo[playerid][pBizKey] != i)
							{
								if(Businesses[i][Locked] == 1 && PlayerInfo[playerid][pAdmin] == 0)
								{
									GameTextForPlayer(playerid, "~r~Business Chiuso.", 5000, 1);
									return 1;
								}
								if(Businesses[i][Products] == 0)
								{
									GameTextForPlayer(playerid, "~r~Enough products.", 5000, 1);
									return 1;
								}
								new businesstype[126];
                                if(Businesses[i][BizType] == 1) { businesstype = "[INFO] Comandi disponibili: /mangia"; }
						        else if(Businesses[i][BizType] == 2) { businesstype = "[INFO] Comandi disponibili: /compracellulare"; }
						        else if(Businesses[i][BizType] == 3) { businesstype = "[INFO] Comandi disponibili: /compra"; }
						        else if(Businesses[i][BizType] == 4) { businesstype = "[INFO] Comandi disponibili: /compraarma"; }
						        else if(Businesses[i][BizType] == 5) { businesstype = "[INFO] Comandi disponibili: /pub"; }
						        else if(Businesses[i][BizType] == 6) { businesstype = "[INFO] Comandi disponibili: /vestiti"; }
						        else if(Businesses[i][BizType] == 7) { businesstype = "[INFO] Comandi disponibili: /bere"; }
						        else if(Businesses[i][BizType] == 12) { businesstype = "[INFO] Comandi disponibili: /comprapc - /installamsn - /installaantivirus"; }
						        else if(Businesses[i][BizType] == 13) { businesstype = "[INFO] Comandi disponibili: /assicura"; }
								PlayerActionMessage(playerid,15.0,"apre la porta ed entra.");
								GivePlayerCash(playerid,-Businesses[i][EntranceCost]);
								format(string, sizeof(string), "[INFO:] Hai pagato $%d per entrare in %s.", Businesses[i][EntranceCost],Businesses[i][BusinessName]);
								SendClientMessage(playerid,COLOR_LIGHTYELLOW2,string);
								SendClientMessage(playerid,COLOR_LIGHTYELLOW2,businesstype);
								Businesses[i][Till] += Businesses[i][EntranceCost];
								Businesses[i][Products]--;
								SetPlayerInterior(playerid,Businesses[i][ExitInterior]);
								SetPlayerPos(playerid,Businesses[i][ExitX],Businesses[i][ExitY],Businesses[i][ExitZ]);
								SetPlayerVirtualWorld(playerid,i);
								SetPlayerFacingAngle(playerid,Businesses[i][ExitAngle]);
								if(Businesses[i][BizType] == 8)
							    {
							        PlayerActionMessage(playerid,15.0,"open door and enter.");
							        SoftAirPlayers ++;
							        SetPlayerVirtualWorld(playerid,0);
							        PlayerSoftAiring[playerid] = 1;
							        SetPlayerInterior(playerid,10);
							        new rand = random(sizeof(SoftAirSpawns));
								    SetPlayerPos(playerid, SoftAirSpawns[rand][0], SoftAirSpawns[rand][1], SoftAirSpawns[rand][2]);
								    TogglePlayerControllable(playerid, 0);
							    }
							    if(Businesses[i][BizType] == 9)
							    {
							        PlayerKarting[playerid] = 1;
							        SendClientMessage(playerid, COLOR_GREEN, "Now you can join Kart Race. Take a Kart.");
							        SetPlayerInterior(playerid,Businesses[i][EnterInterior]);
							        SetPlayerVirtualWorld(playerid,Businesses[i][EnterWorld]);
							        SetPlayerPos(playerid,Businesses[i][EnterX],Businesses[i][EnterY],Businesses[i][EnterZ]);
							        SetPlayerFacingAngle(playerid,Businesses[i][EnterAngle]);
							    }
								SaveBusinesses();
							}
							else
							{
								new businesstype[126];
                                if(Businesses[i][BizType] == 1) { businesstype = "[INFO] Comandi disponibili: /mangia"; }
						        else if(Businesses[i][BizType] == 2) { businesstype = "[INFO] Comandi disponibili: /compracellulare"; }
						        else if(Businesses[i][BizType] == 3) { businesstype = "[INFO] Comandi disponibili: /compra"; }
						        else if(Businesses[i][BizType] == 4) { businesstype = "[INFO] Comandi disponibili: /compraarma"; }
						        else if(Businesses[i][BizType] == 5) { businesstype = "[INFO] Comandi disponibili: /pub"; }
						        else if(Businesses[i][BizType] == 6) { businesstype = "[INFO] Comandi disponibili: /vestiti"; }
						        else if(Businesses[i][BizType] == 7) { businesstype = "[INFO] Comandi disponibili: /bere"; }
						        else if(Businesses[i][BizType] == 12) { businesstype = "[INFO] Comandi disponibili: /comprapc - /installamsn - /installaantivirus"; }
                                PlayerActionMessage(playerid,15.0,"open door and enter.");
								SendClientMessage(playerid,COLOR_LIGHTYELLOW2,"[INFO:] Free entry for owner.");
								SendClientMessage(playerid,COLOR_LIGHTYELLOW2, businesstype);
								SetPlayerInterior(playerid,Businesses[i][ExitInterior]);
								SetPlayerPos(playerid,Businesses[i][ExitX],Businesses[i][ExitY],Businesses[i][ExitZ]);
								SetPlayerVirtualWorld(playerid,i);
								SetPlayerFacingAngle(playerid,Businesses[i][ExitAngle]);
								if(Businesses[i][BizType] == 8)
							    {
							        SoftAirPlayers ++;
							        SetPlayerVirtualWorld(playerid,0);
							        PlayerSoftAiring[playerid] = 1;
							        SetPlayerInterior(playerid,10);
							        new rand = random(sizeof(SoftAirSpawns));
								    SetPlayerPos(playerid, SoftAirSpawns[rand][0], SoftAirSpawns[rand][1], SoftAirSpawns[rand][2]);
								    TogglePlayerControllable(playerid, 0);
							    }
							    if(Businesses[i][BizType] == 9)
							    {
							        PlayerKarting[playerid] = 1;
							        SendClientMessage(playerid, COLOR_GREEN, "Now you can join Kart Race. Take a Kart.");
							        SetPlayerInterior(playerid,Businesses[i][EnterInterior]);
							        SetPlayerVirtualWorld(playerid,Businesses[i][EnterWorld]);
							        SetPlayerPos(playerid,Businesses[i][EnterX],Businesses[i][EnterY],Businesses[i][EnterZ]);
							        SetPlayerFacingAngle(playerid,Businesses[i][EnterAngle]);
							    }
							}
						}
						else
						{
							SendClientMessage(playerid,COLOR_LIGHTYELLOW2,"[ERROR:] You haven't enough money to enter!");
						}
					}
				}
			}
		return 1;
	}

3) I want to change the faction names. I have to change their name on spawno? Just replacing all the times their name appears, faction name is changed?


4) I want to change the interior of a business. Where i can find the business string on spawno?


5) When i exit from the game, next time i log in, i spawn at the civilian spawnpoint. I want that the server record last position and the player spawn there.



6) I want that the button to start a vehicle is "2". But on my GM is setted to TAB.

I'll show you my vehicle script:

Код:
new vehicleid = GetPlayerVehicleID(playerid);
if (CarShopping[playerid] == false)
{
	if(newkeys == KEY_ACTION)
	{
		if(IsPlayerInAnyVehicle(playerid))
		{
		    if(vEngine[vehicleid] == 0 && !IsRentVehicle(vehicleid))
		    {
                if(vehicleid>=210 && vehicleid<=235 && RentedVehicle[playerid] != vehicleid) return 1;
                if(vTicket[vehicleid] > 0) return 1;
				if(OutOfFuel[playerid]) return SendClientMessage(playerid, YELLOW, "Enough fuel.");
				if(TryEngine[playerid]) return 1;
                SetTimerEx("EngineOn", 3000, 0, "d", playerid);
                PlayerActionMessage(playerid, 15.0, "try to start engine.");
                TryEngine[playerid] = 1;
                GameTextForPlayer(playerid, "~r~try to start engine.", 3000, 5);
				return 1;
			}
		}
	}
	if(newkeys == KEY_SUBMISSION)
	{
		if(IsPlayerInAnyVehicle(playerid))
		{
			if(vEngine[vehicleid] == 1 && !IsRentVehicle(vehicleid))
		    {
                vEngine[vehicleid] = 0;
			    TogglePlayerControllable(playerid, 0);
			    GameTextForPlayer(playerid, "~r~setted engine off.", 3000, 5);
                BrowsingCar = 1;
                SendClientMessage(playerid, YELLOW, "Engine Off, press TAB to set engine ON.");
				return 1;
			}
		}
    }
   	if(newkeys == KEY_SECONDARY_ATTACK)
	{
		if(IsPlayerInAnyVehicle(playerid))
		{
		    if(BrowsingCar == 1)
		    {
		        RemovePlayerFromVehicle(playerid);
		        TogglePlayerControllable(playerid, 1);
                BrowsingCar = 0;
				return 1;
			}
		}
    }
}
So i replaced in first newkeys KEY_ACTION with KEY_SUBMISSION (that is 2 on keyboard, because in this script, if i press TAB it gets ON, if i press 2 it gets OFF) but when i press 2 the engine doesn't start!!
My idea is to set "2" like a toggle, start and stop engines!

PS: Pawno show 0 errors.
PPS: If it is not possible, can you suggest me a key to start engine that isn't TAB (because TAB is the key to show users online...)


7) I want insert the "i" of information in some places, for example in the LSPD for starting duty. What is the code?


8 ) I want that out of the business appears the type of business. Like 24/7, Pubblicity, Restaurant etc... In my GM appears just "business" on the house logo...


I give you my .pwn file (in a file text that you can download below). The text are in italian...i can't traduce all the file... but the command to enter or exit from a building are:
"/entra" to enter, "/esci" to exit (so you can find it fastly).

DOWNLOAD PWN FILE:
http://www.mediafire.com/?dozfczg3vvs11k3


Thank you for helping. Marco.
Reply
#2

Quote:

1) I want remove the text that appears when i go near a house or a business. It's "House: Type /enter to enter.". I searched in pawno this text but it doesn't exist!!

Search for 3DTextLabel, that is the function it will be created under.

Quote:

2) I want that i have to press the enter key to enter into a business or in a house! I tried with:
Код:
public OnPlayerKeyStateChange (playerid, newkeys)

if(newkeys == KEY_SECONDARY_ATTACK)
{
my enter script
}
but it says to me that "newkeys" is an undefined symbol.

Make sure that your function deceleration is correct, it should be public OnPlayerKeyStateChange(playerid, oldkeys, newkeys)

Also you should use if(newkeys & KEY_SECONDARY_ATTACK) not ==, see here for why.

Quote:

3) I want to change the faction names. I have to change their name on spawno? Just replacing all the times their name appears, faction name is changed?

Most likely, yes.

Quote:

4) I want to change the interior of a business. Where i can find the business string on spawno?

If you are using a static system then the position of the player is probably set after they enter with SetPlayerPos

Quote:

5) When i exit from the game, next time i log in, i spawn at the civilian spawnpoint. I want that the server record last position and the player spawn there.

You'll have to save the players position to a variable in their player file and load it when they login next time.

Quote:

6) I want that the button to start a vehicle is "2". But on my GM is setted to TAB.

The 2 key can not be detected as being pressed unless one of the default keys is bound to it. If there is a key bound to it then try changing your == to & (see above for explanation)

Quote:

7) I want insert the "i" of information in some places, for example in the LSPD for starting duty. What is the code?

CreatePickup

Based on what you've said, I highly recommend that you start with something more simple for scripting. You are not going to find people to make your script for you on these forums, so follow some tutorial on these forums and the wiki and read some scripts to get a better understanding of scripting.
Reply
#3

Hi! Thank you for velocity!

I started this morning with pawno, but i studied something of C++... i'm reading lots of tutorial... However, Thank you for answering!!


I tried the solution you suggest me...but it doesn't work...i think that i have to study a lot...i dont understand the answer about the business position...and so how to change interior...
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)