[Tutorial] Roleplay GM (STARTER)
#1




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}"
Lets Begin:
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
And also remove this, so that you don't get the error:

Code:
#endif
Moving Ahead:
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");
}
Now, write the GameModeText in the SetGameModeText option. Then, remove these lines from the public OnGameModeInit(). Note that the bold lines are to be removed:
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;
}
As, we are making a Roleplay gamemode, we don't want to let players change their class(skin) or something like that, so remove this shit from public OnPlayerRequestClass(playerid, classid). Remove the bold lines:

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;
Registration/Login System:
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;
        }
    }
}
Then, you also don't want everyone to see your Roleplay, so add this under your current stock:

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);
        }
    }
}
Then, add this under your previous stock:
Code:
stock GetName(playerid)
{
    new name[24];
    GetPlayerName(playerid, name, sizeof(name));
    strreplace(name, '_', ' ');
    return name;
}
Your stocks are done. Now lets move towards our commands.

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;
}
Add this at the last:
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;
}
/s(hout):
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;
}
/b:
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;
}
At the end:
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
__________________________________________________ _______________________________________________
Reply
#2

Nice tutorial!
Reply
#3

Quote:
Originally Posted by JordanDoughty
View Post
Nice tutorial!
I am glad that you like it..
Reply
#4

Good TUT, really useful for newbies! But still not +REP *** Joke, you just earned a REP!***
Reply
#5

Quote:
Originally Posted by FernandoLight
View Post
Good TUT, really useful for newbies! But still not +REP *** Joke, you just earned a REP!***
Thanks for your nice reply, but i don't see any REP in my reputation bar. Yano, its still 0.
Reply
#6

Isn't it ironic that I posted a topic on why you should not use stock, just this morning? And yet I see:

Quote:
Originally Posted by JasonSolarin
View Post
Stocks, ProxDetector:
Don't worry, a stock can do this thing for you

Your stocks are done. Now lets move towards our commands.
Sad.
Reply
#7

Quote:
Originally Posted by Vince
View Post
Isn't it ironic that I posted a topic on why you should not use stock, just this morning? And yet I see:



Sad.
OFF TOPIC:Yeah, that is quite sad, stocks are abused all the time by a lot of newly scripters.
I myself still use stocks even for little things.
Maybe one day I myself will understand correctly how to script without using stocks.

Anywho, nice tutorial I am sure a lot of people will find this good
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)