03.02.2009, 09:11
Hello all. In this tutorial, I will show scripting beginers, how to make /enter and /exit for house. First of all, copy this into your script (bottom of script).
This will get players position (for enter icon) with radius. Now, let's start.
So, you've decided to make police department. So, you go to police department in debug and type /save to get coordinates for enterance and for icon. When you get your coordinates (example: 2290.0496,2430.2283,10.8203), you can create icon at police department. So you make icon at OnGameModeInit(). First disable enter/exit (yellow thingy) with adding line under OnGameModeInt()
Then add:
So, now we created icon (Info icon...) at PD. Now we have to script /enter and /exit command right? You do it like this.
Under OnPlayerCommandText(playerid, cmdtext[]) you can script every player command. So, lets make /enter shall we?
Now we made /enter but we need to get out, right?
Код:
stock PlayerToPoint(Float:radi, playerid, Float:x, Float:y, Float:z) { new Float:oldposx, Float:oldposy, Float:oldposz; new Float:tempposx, Float:tempposy, Float:tempposz; GetPlayerPos(playerid, oldposx, oldposy, oldposz); tempposx = (oldposx -x); tempposy = (oldposy -y); tempposz = (oldposz -z); if (((tempposx < radi) && (tempposx > -radi)) && ((tempposy < radi) && (tempposy > -radi)) && ((tempposz < radi) && (tempposz > -radi))) { return 1; } return 0; }
So, you've decided to make police department. So, you go to police department in debug and type /save to get coordinates for enterance and for icon. When you get your coordinates (example: 2290.0496,2430.2283,10.8203), you can create icon at police department. So you make icon at OnGameModeInit(). First disable enter/exit (yellow thingy) with adding line under OnGameModeInt()
Код:
DisableInteriorEnterExits();
Код:
CreatePickup(1239,1,2290.0496,2430.2283,10.8203); // ICON for POLICE DEPARTMENT
Under OnPlayerCommandText(playerid, cmdtext[]) you can script every player command. So, lets make /enter shall we?
Код:
if(strcmp(cmdtext, "/enter", true, 6) == 0) { if(PlayerToPoint(3, playerid, 2290.0496,2430.2283,10.8203)) // Police enterance { SetPlayerInterior(playerid, 3); // This is important! This sets player to interior id 3! SetPlayerPos(playerid, 238.6620,141.0520,1003.0234); // these are coordinates where he'll spawn (PD INT) return 1; } return 1; }
Код:
if (strcmp(cmdtext, "/exit", true, 5) == 0) { if(PlayerToPoint(3, playerid, 238.6620,141.0520,1003.0234)) // Police enterance { SetPlayerInterior(playerid, 0); // this is important..interior 0 is outside... SetPlayerPos(playerid, 2290.0496,2430.2283,10.8203); // this is where player will stand... return 1; } return 1; } That's basicly it...If you dont understand what line means, just say it here. I'll explain. Thanks for reading. Bye!