12.04.2015, 16:46
(
Last edited by JasonSolarin; 12/04/2015 at 04:59 PM.
Reason: Minor Changes
)
Introduction:
To start with, let me first introduce myself. I am JasonSolarin. I have started scripting like 1 year ago and now I am a bit good as I learnt the basics and other things. I made my own scratch-made Roleplay Gamemode. This is my first tutorial and first thread, So I hope that you guys will like it.
Includes and Colors needed:
We need following includes and colors for our gamemode. Just click the includes one by one and their download link will also appear with them:
Includes:
Colors:
Code:
#define COLOR_PURPLE 0x800080FF #define COLOR_GREY 0xAFAFAFAA #define COL_WHITE "{FFFFFF}" #define COL_RED "{F81414}" #define COL_GREEN "{00FF22}" #define COL_LIGHTBLUE "{00CED1}"
Okay, to begin with, I would recommend that you use 0.3z-R2 Server as most of the SA-MP is still based on 0.3z. You can also use 0.3.7 but, I mostly recommend that you use this one. You can get the SA-MP 0.3z-R2 Server here:
SA-MP Server. Extract the server, go to the folder named "Pawno" and open "pawno.exe" in it. Press the NEW button found in the top-left corner. (You can also go to FILE Menu and then press NEW, or simply press CTRL+N). You will get some lines written on it. You just have to remove these lines as we are creating a gamemode:
Code:
#if defined FILTERSCRIPT public OnFilterScriptInit() { print("\n--------------------------------------"); print(" Blank Filterscript by your name here"); print("--------------------------------------\n"); return 1; } public OnFilterScriptExit() { return 1; } #else
Code:
#endif
Lets move a bit ahead, you need to assign your gamemode as specific name, right? Write you gamemode name in these lines:
Code:
main() { print("\n----------------------------------"); print(" Blank Gamemode by your name here"); print("----------------------------------\n"); }
Code:
public OnGameModeInit() { // Don't use these lines if it's a filterscript SetGameModeText("Blank Script"); AddPlayerClass(0, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0); return 1; }
Code:
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;
Next part of the roleplay gamemode is to have a registration and a login system which is collectively called Server Database System. I would recommend that all of you use the Kush's Y_ini tutorial as I use it and it is proved to be a successful database management system. You can find the Kush's tutorial here: Kush's Login and Registration System
However, you can also use other database management system but I recommend Kush's System.
Chat Commands:
The most important part of a roleplay gamemode is its chatting system with /me, /do, /s commands.
Note: I won't tell how these systems work because this thread is mainly based on the Roleplay Gamemode Creation. You either have to find it out or you can just copy-paste these commands to make your GM quickly.
Stocks, ProxDetector:
First of all, you all should want your server not to mention this thing " **Player_Name sits down " . You probably don't want the underscore " _ ". Don't worry, a stock can do this thing for you. Add this under your includes:
Code:
stock strreplace(string[], find, replace) { for(new i=0; string[i]; i++) { if(string[i] == find) { string[i] = replace; } } }
Code:
stock ProxDetector(Float:radi, playerid, string[],color) { new Float:x,Float:y,Float:z; GetPlayerPos(playerid,x,y,z); foreach(Player,i) { if(IsPlayerInRangeOfPoint(i,radi,x,y,z)) { SendClientMessage(i,color,string); } } }
Code:
stock GetName(playerid) { new name[24]; GetPlayerName(playerid, name, sizeof(name)); strreplace(name, '_', ' '); return name; }
Chat Commands:
The most important commands of a roleplay gamemode are /me, /do, /s, /b.
/me:
Use this at the last of your gamemode, at the last, even under:
Code:
public OnPlayerClickPlayer(playerid, clickedplayerid, source) { return 1; }
Code:
CMD:me(playerid, params[]) { new string[128]; if (isnull(params)) { SendClientMessage(playerid, -1, "USAGE: /me [action]"); } else { format(string, sizeof(string), "* %s %s", GetName(playerid), params); ProxDetector(30, playerid, string, COLOR_PURPLE); } return 1; }
/do:
After your /me command, at this under it:
Code:
CMD:do(playerid, params[]) { new string[128], action[100]; if(sscanf(params, "s[100]", action)) { SendClientMessage(playerid, -1, "USAGE: /do [action]"); return 1; } else { format(string, sizeof(string), "* %s (( %s ))", action, GetName(playerid)); ProxDetector(30, playerid, string, COLOR_PURPLE); } return 1; }
Now for your shout command, add this under the /do command:
Code:
CMD:s(playerid, params[]) { new string[128], shout[100]; if(sscanf(params, "s[100]", shout)) { SendClientMessage(playerid, -1, "USAGE: /(s)hout [message]"); return 1; } else { format(string, sizeof(string), "%s shouts: %s!",GetName(playerid),shout); ProxDetector(50.0, playerid, string, -1); } return 1; }
Also, you need a local OOC Command, right? For this purpose, add this under your /s command:
Code:
CMD:b(playerid, params[]) { new string[128], text[100]; if(sscanf(params, "s[100]", text)) return SendClientMessage(playerid, -1, "USAGE: /b [TEXT]"); format(string, sizeof(string), "(( %s says: %s ))", GetName(playerid), text); ProxDetector(30.0, playerid, string, COLOR_GREY); return 1; }
Finally, You guys must be thinking what a boring tutorial it was, but I hope that it really helped those guys who didn't know how to make a Simple RP Gamemode. At the end, I would like to say that if there are any errors in the scripting, do not reply to this thread, instead, PM me and I will PM you with its fix. Please REP+ me if you guys like this tutorial.
Now, You guys can add many different systems like faction, phone, banking system etc. which you can add either from SA-MP Forums as a tutorial or you can add as a filterscript. I mostly recommend that you use SAMP Forums as they also provide necessary information and their replies to verify if the system works or not. I am real sorry as I cannot tell you how to make Admin System but i promise that this link would be helpful in this case : Useful Tutorials. You can find dozens of things over here. I did not have anytime to tell you how to make admin system, i had to do many kinds of work.. so.. sorry once again.
Credits:
At the end, I would like to give credits to the following persons:
Y_Less
Zeex
Killer98p
Kush
BlacK
Xicor(Thanks for telling me about SA-MP)
Blademaster680
__________________________________________________ _______________________________________________
Zeex
Killer98p
Kush
BlacK
Xicor(Thanks for telling me about SA-MP)
Blademaster680