[Tutorial] Making A Class System(Very Simple+Easy+Dialogs+Texts)
#13

pawn Code:
enum { Soldier, Sniper, Engineer, JetTrooper, Pilot, Spy };
enum PlayerInfo { Team };
new Info[MAX_PLAYERS][PlayerInfo];

//So instead of #define a hundred times, a simple enum..and an info array instead of a gPlayerClass array.
//This way they can put Kills etc into that single array instead of making a new one.

if(!strcmp(cmdtext, "/jetpack", true))
{
    if(Info[playerid][Team] != JetTrooper) return SendClientMessage(playerid, 0xCC0000AA, "You aren't a Jet Trooper!");
    SetPlayerSpecialAction(playerid,2);
    return 1;
}

//or

CMD:jetpack(playerid, params[])
{
    if(Info[playerid][Team] != JetTrooper) return SendClientMessage(playerid, 0xCC0000AA, "You aren't a Jet Trooper!");
    SetPlayerSpecialAction(playerid,2);
    return 1;
}

//That's an example on what I mean by a different array
Also, you have NO need to do that many things in your team vehicles (it's not score required I don't know why you'd call it that)...

pawn Code:
if(GetVehicleModel(vehicleid) == 425 && gPlayerClass[playerid] == SOLDIER && gPlayerClass[playerid] == SNIPER && gPlayerClass[playerid] == ENGINEER && gPlayerClass[playerid] == JETROOPER && gPlayerClass[playerid] == SPY)//if player is pilot then he can drive
{
    SendClientMessage(playerid, COLOR_RED, "You Need to  be a Pilot to fly Hunter");//messages goes to the player that he can't drive the hunter
    RemovePlayerFromVehicle(playerid);//get u off from the hunter
}

//can be

if(Info[playerid][Team] != Pilot && GetVehicleModel(vehicleid) == 425)
{
    SendClientMessage(playerid, COLOR_RED, "You Need to  be a Pilot to fly Hunter");
    RemovePlayerFromVehicle(playerid);
}
I'd also like to note, using an else if is a much better thing to do in this situation. The code is still going to run through the checks even if you've found the proper vehicle model.

pawn Code:
if(something) //if this isn't found THEN
else if(somethingelse) //we check this, if it isn't found
else if(somethingelseagain) //we check this
else //if nothing is found above, we do this
is a better method

pawn Code:
if(something) //ok we found this
if(somethingelse) //we found this too, so we run it
if(blahblah) //we found this so we're still gonna do it
This is what you're doing

https://sampwiki.blast.hk/ look around there...
Reply


Messages In This Thread
Making A Class System(Very Simple+Easy+Dialogs+Texts) - by $$inSane - 08.05.2012, 15:46
Re: Making A Class System(Very Simple+Easy+Dialogs+Texts) - by $$inSane - 08.05.2012, 16:04
Re: Making A Class System(Very Simple+Easy+Dialogs+Texts) - by iOmar - 08.05.2012, 17:02
Re: Making A Class System(Very Simple+Easy+Dialogs+Texts) - by $$inSane - 09.05.2012, 08:55
Re: Making A Class System(Very Simple+Easy+Dialogs+Texts) - by JaKe Elite - 09.05.2012, 09:18
Re: Making A Class System(Very Simple+Easy+Dialogs+Texts) - by $$inSane - 09.05.2012, 09:28
Re: Making A Class System(Very Simple+Easy+Dialogs+Texts) - by BigETI - 09.05.2012, 11:40
Re: Making A Class System(Very Simple+Easy+Dialogs+Texts) - by iOmar - 09.05.2012, 12:19
Re: Making A Class System(Very Simple+Easy+Dialogs+Texts) - by Rudy_ - 09.05.2012, 12:25
Re: Making A Class System(Very Simple+Easy+Dialogs+Texts) - by $$inSane - 09.05.2012, 15:07
Re: Making A Class System(Very Simple+Easy+Dialogs+Texts) - by iOmar - 09.05.2012, 17:17
Re: Making A Class System(Very Simple+Easy+Dialogs+Texts) - by $$inSane - 10.05.2012, 08:49
Re: Making A Class System(Very Simple+Easy+Dialogs+Texts) - by [ABK]Antonio - 10.05.2012, 09:45
Re: Making A Class System(Very Simple+Easy+Dialogs+Texts) - by Slix_ - 10.05.2012, 09:48
Re: Making A Class System(Very Simple+Easy+Dialogs+Texts) - by iOmar - 10.05.2012, 10:21
Re: Making A Class System(Very Simple+Easy+Dialogs+Texts) - by $$inSane - 10.05.2012, 13:47
Re: Making A Class System(Very Simple+Easy+Dialogs+Texts) - by $$inSane - 14.05.2012, 11:13
Re: Making A Class System(Very Simple+Easy+Dialogs+Texts) - by Gangs_Rocks - 19.05.2012, 15:30
Re: Making A Class System(Very Simple+Easy+Dialogs+Texts) - by $$inSane - 19.05.2012, 16:08
Re: Making A Class System(Very Simple+Easy+Dialogs+Texts) - by ℓмяαη_кнαη - 19.05.2012, 16:51
Re: Making A Class System(Very Simple+Easy+Dialogs+Texts) - by $$inSane - 19.05.2012, 17:12
Re: Making A Class System(Very Simple+Easy+Dialogs+Texts) - by $$inSane - 21.05.2012, 09:05
Re: Making A Class System(Very Simple+Easy+Dialogs+Texts) - by [GF]Logic - 23.05.2012, 12:56
Re: Making A Class System(Very Simple+Easy+Dialogs+Texts) - by Luis- - 23.05.2012, 14:20
Re: Making A Class System(Very Simple+Easy+Dialogs+Texts) - by Coder_ - 04.07.2012, 17:55
Re: Making A Class System(Very Simple+Easy+Dialogs+Texts) - by $$inSane - 07.07.2012, 09:33
Re: Making A Class System(Very Simple+Easy+Dialogs+Texts) - by $$inSane - 07.07.2012, 14:00
Re: Making A Class System(Very Simple+Easy+Dialogs+Texts) - by Lordzy - 07.07.2012, 14:09
Re: Making A Class System(Very Simple+Easy+Dialogs+Texts) - by $$inSane - 07.07.2012, 14:13
Re: Making A Class System(Very Simple+Easy+Dialogs+Texts) - by Biess - 26.08.2012, 10:47
Re: Making A Class System(Very Simple+Easy+Dialogs+Texts) - by DeadLy™ - 26.08.2012, 17:26
Re: Making A Class System(Very Simple+Easy+Dialogs+Texts) - by JimmyCh - 24.06.2013, 10:43
Re: Making A Class System(Very Simple+Easy+Dialogs+Texts) - by Chrisis - 01.07.2013, 07:32
Re: Making A Class System(Very Simple+Easy+Dialogs+Texts) - by Mckarlis - 30.07.2013, 22:45
Re: Making A Class System(Very Simple+Easy+Dialogs+Texts) - by qazwsx - 02.08.2013, 09:07
Re: Making A Class System(Very Simple+Easy+Dialogs+Texts) - by qazwsx - 12.08.2013, 04:58
Re: Making A Class System(Very Simple+Easy+Dialogs+Texts) - by usamahifi - 07.02.2015, 18:01
Re: Making A Class System(Very Simple+Easy+Dialogs+Texts) - by $$inSane - 09.02.2015, 08:51
Re: Making A Class System(Very Simple+Easy+Dialogs+Texts) - by $$inSane - 25.07.2015, 08:42
Re: Making A Class System(Very Simple+Easy+Dialogs+Texts) - by Hemeei - 25.07.2015, 09:55
Re: Making A Class System(Very Simple+Easy+Dialogs+Texts) - by Snipa - 26.07.2015, 17:12
Re: Making A Class System(Very Simple+Easy+Dialogs+Texts) - by $$inSane - 27.07.2015, 10:09
Re: Making A Class System(Very Simple+Easy+Dialogs+Texts) - by Glossy42O - 27.07.2015, 10:18
Re: Making A Class System(Very Simple+Easy+Dialogs+Texts) - by Snipa - 28.07.2015, 01:11

Forum Jump:


Users browsing this thread: 1 Guest(s)