07.11.2010, 06:21
(
Последний раз редактировалось Lesinorion; 22.11.2010 в 03:22.
)
Menu Selection
Maybe you have ask.. How can I make a Menu Selection?Something like this:
Well in this post i will show you, how you can do it for your own server.
In my example i will use Streamer
Download: https://sampforum.blast.hk/showthread.php?tid=102865
Streamer is needed to use:
pawn Код:
CreateDynamicCP(Float:x, Float:y, Float:z, Float:size, worldid = -1, interiorid = -1, playerid = -1, Float:distance = 100.0);
IsPlayerInDynamicCP(playerid, checkpointid);
The First that you need to do to begin is add the include to you GameMode/Filterscript like this:
pawn Код:
#include <streamer>
First:
pawn Код:
new Text:TextDraw1;
pawn Код:
TextDraw1= TextDrawCreate(15.000000, 170.000000, "~n~~y~ Weapons:~n~~n~~y~1.~w~Chainsaw ~g~$5000~n~~y~2.~w~Desert ~g~$2500~n~~y~3.~w~Sawnoff ~g~$3500~n~~y~4.~w~Combat ~g~$5000~n~~y~5.~w~Tec9 ~g~$6000~n~~y~6.~w~MP5 ~g~$7500~n~~y~7.~w~M4 ~g~$8000~n~~y~8.~w~Sniper ~g~$10000~n~~y~9.~w~Armor ~g~$1000~n~");
TextDrawFont(TextDraw1, 1);
TextDrawTextSize(TextDraw1,145.000000, 260.000000);
TextDrawLetterSize(TextDraw1,0.299999,0.800000);
TextDrawUseBox(TextDraw1, 1);
TextDrawBoxColor(TextDraw1, 0x000000FF);
Now create the checkpoint:
First:
pawn Код:
new:Checkpoint1;
pawn Код:
public OnGameModeInit()
{
Checkpoint1= CreateDynamicCP (313.9218,-133.6192,999.6016, 1.5, -1, -1, -1, 7.0); // Checkpoint in the ammun nation
return 1;
}
If the checkpoint and the TextDraw are ready to use, you have to add this:
pawn Код:
public OnPlayerEnterDynamicCP(playerid, checkpointid)
{
if(GetPlayerState(playerid) == PLAYER_STATE_ONFOOT)
{
if(checkpointid == Checkpoint1) // This is what the checkpoint will do
{
TextDrawShowForPlayer(playerid, TextDraw1); // Funtion, in this case the checkpoint only will show the TextDraw
}
}
return 1;
}
If it isn't like that, you have to verify all that you did
Well, If everything is in order, you have to add this code:
pawn Код:
public OnPlayerText(playerid, text[])
{
if(text[0] == '1') // Chainsaw
if(IsPlayerInDynamicCP(playerid, Checkpoint1)) // This will work, only if you are in the checkpoint
{
if(GetPlayerMoney(playerid) <5000) return SendClientMessage(playerid,ROJO, "You Dont Have Enogh Money"); // if you do not have the specific money, it will say the "you dont have enough money"
GivePlayerMoney(playerid,-5000); // The Weapon Cost
GivePlayerWeapon(playerid,9,0);
return 0;
}
if(text[0] == '2') //Desert Eagle
if(IsPlayerInDynamicCP(playerid, Checkpoint1)) // This will work, only if you are in the checkpoint
{
if(GetPlayerMoney(playerid) <2500) return SendClientMessage(playerid,ROJO, "You Dont Have Enogh Money"); // if you do not have the specific money, it will say the "you dont have enough money"
GivePlayerMoney(playerid,-2500); // The Weapon Cost
GivePlayerWeapon(playerid,24,150);
return 0;
}
if(text[0] == '3') //Sawnoff Shotgun
if(IsPlayerInDynamicCP(playerid, Checkpoint1)) // This will work, only if you are in the checkpoint
{
if(GetPlayerMoney(playerid) <3500) return SendClientMessage(playerid,ROJO, "You Dont Have Enogh Money"); // if you do not have the specific money, it will say the "you dont have enough money"
GivePlayerMoney(playerid,-3500); // The Weapon Cost
GivePlayerWeapon(playerid,26,150);
return 0;
}
if(text[0] == '4') //Combat Shotgun
if(IsPlayerInDynamicCP(playerid, Checkpoint1)) // This will work, only if you are in the checkpoint
{
if(GetPlayerMoney(playerid) <5000) return SendClientMessage(playerid,ROJO, "You Dont Have Enogh Money"); // if you do not have the specific money, it will say the "you dont have enough money"
GivePlayerMoney(playerid,-5000); // The Weapon Cost
GivePlayerWeapon(playerid,27,150);
return 0;
}
if(text[0] == '5') //Tec9
if(IsPlayerInDynamicCP(playerid, Checkpoint1)) // This will work, only if you are in the checkpoint
{
if(GetPlayerMoney(playerid) <6000) return SendClientMessage(playerid,ROJO, "You Dont Have Enogh Money"); // if you do not have the specific money, it will say the "you dont have enough money"
GivePlayerMoney(playerid,-6000); // The Weapon Cost
GivePlayerWeapon(playerid,32,200);
return 0;
}
if(text[0] == '6') //MP5
if(IsPlayerInDynamicCP(playerid, Checkpoint1)) // This will work, only if you are in the checkpoint
{
if(GetPlayerMoney(playerid) <7500) return SendClientMessage(playerid,ROJO, "You Dont Have Enogh Money"); // if you do not have the specific money, it will say the "you dont have enough money"
GivePlayerMoney(playerid,-7500); // The Weapon Cost
GivePlayerWeapon(playerid,29,200);
return 0;
}
if(text[0] == '7') //M4
if(IsPlayerInDynamicCP(playerid, Checkpoint1)) // This will work, only if you are in the checkpoint
{
if(GetPlayerMoney(playerid) <8000) return SendClientMessage(playerid,ROJO, "You Dont Have Enogh Money"); // if you do not have the specific money, it will say the "you dont have enough money"
GivePlayerMoney(playerid,-8000); // The Weapon Cost
GivePlayerWeapon(playerid,31,250);
return 0;
}
if(text[0] == '8') //Sniper
if(IsPlayerInDynamicCP(playerid, Checkpoint1)) // This will work, only if you are in the checkpoint
{
if(GetPlayerMoney(playerid) <10000) return SendClientMessage(playerid,ROJO, "You Dont Have Enogh Money"); // if you do not have the specific money, it will say the "you dont have enough money"
GivePlayerMoney(playerid,-10000); // The Weapon Cost
GivePlayerWeapon(playerid,34,100);
return 0;
}
if(text[0] == '9') //Armor
if(IsPlayerInDynamicCP(playerid, Checkpoint1)) // This will work, only if you are in the checkpoint
{
if(GetPlayerMoney(playerid) <1000) return SendClientMessage(playerid,ROJO, "You Dont Have Enogh Money"); // if you do not have the specific money, it will say the "you dont have enough money"
GivePlayerMoney(playerid,-1000); // The Weapon Cost
SetPlayerArmour(playerid,100);
return 0;
}
return 1;
}
With this tutorial you can do the same but with diferents funtions, checkpoints and TextDraws.
Thats all.
Thanks You!