Something I just cant get!
#1

Hey everyone, Im trying to do some stuff with my jobs and I cant figure out how to do this.
Iv created a dialog where you choose a job you want to have.
pawn Код:
CMD:joblist(playerid, params[])
{
    if(!IsPlayerLoggedIn(playerid)) return SendClientMessage(playerid, COLOR_RED, "You need to login first before using any command.");
    if(!IsPlayerInRangeOfPoint(playerid,2,387.0219,173.7238,1008.3828) && !IsPlayerInRangeOfPoint(playerid,2,1422.5873,-1844.9670,13.5469)) return SendClientMessage(playerid, COLOR_GREY, "You aren't at a job zone.");
    if(PlayerInfo[playerid][pJob] && PlayerInfo[playerid][pVIP] < 2) return SendClientMessage(playerid, COLOR_GREY, "You already have a job.");
    if(PlayerInfo[playerid][pJob] && PlayerInfo[playerid][pVIPJob] && PlayerInfo[playerid][pVIP] >= 2) return SendClientMessage(playerid, COLOR_GREY, "You already have two jobs, /quitjob then try again.");
    if(IsPlayerInRangeOfPoint(playerid,2,387.0219,173.7238,1008.3828)) ShowDialog(playerid, 31);
    else if(IsPlayerInRangeOfPoint(playerid,2,1422.5873,-1844.9670,13.5469)) ShowDialog(playerid, 32);
    return 1;
}
The problem im having is the player is able to have two jobs if they are VIP. I need a way so they cant get the same job twice if they choose a job they arealy have. Here is what happens at the moment if they choose mechanic:
pawn Код:
if(!PlayerInfo[playerid][pJob]) PlayerInfo[playerid][pJob] = JOB_MECHANIC;
                    else if(PlayerInfo[playerid][pVIP] >= 2) PlayerInfo[playerid][pVIPJob] = JOB_MECHANIC;
                    SendClientMessage(playerid, COLOR_LIGHTBLUE, "* You have joined the {FF6347}Mechanic {33CCFF}job, type /help to view your job commands.");
I want to make it so If they have no job at all then pJob will be set to mechanic. Otherwise if they do have a job and they arent level 2 VIP then a message saying "you already have a job" or if they are already a mechanic then "you are already a mechanic."
But if they are vip it will check if they have no job in vip slot, etc..
Can someone please help me with this, Id be greatly apreciative!
Reply
#2

On your enumaration of player info,I bet pJob looks like this:
pawn Код:
enum
{
   pJob
}
Change it to:
pawn Код:
enum
{
  pJob[128]
}
Now,it's a string and you format it like this:
pawn Код:
format(PlayerInfo[playerid][pJob],128,"JOB_MECHANIC");
Then read it and see if he has a job...Not sure it'll work:
pawn Код:
if(!PlayerInfo[playerid][pJob][0])//he doesn't have a job
pawn Код:
if(PlayerInfo[playerid][pJob][0] != 0)//he has a job
Reply
#3

Theres goto be an easier way?
When the player doesnt have a job its set to JOB_NONE
and iv got other jobs like JOB_SKIPPER and JOB_TAXI etc..
Reply
#4

Sorry,I don't think there's another way,what do you loose if you try?And maybe it works,so..After you checked if the player has a job using the statement I gave you,DO NOT CHECK what job he does have anymore,only if he has one,and therefor send him a message he alread has a job,meaning that you can even use a variable instead of job strings,0 he has no jobs,1,he has a job...
Reply
#5

I thought we were not authorized to place array in enums. Am I right?
Reply
#6

Quote:
Originally Posted by lelemaster
Посмотреть сообщение
I thought we were not authorized to place array in enums. Am I right?
Sureee,then,if you can do it,make a vehicle system(dealership),or buyable house system,but STORE THE Owner,player's name into a variable and write it in a DataBase,without arrays
pawn Код:
enum hinfo
{
    owner[24],
    Hname[100],
    costprice,
    Float:EnterPos[3],
    Float:TelePos[3],
    sellprice,
    interiors,
    Text3D:textid,
    checkpointidx[2]
};
Script that whole piece of code without arrays..
Reply
#7

It would seem that this works for what I want but The message still comes up. How can I arrange it so the message comes up if you actually change your job yet error messages come up if didnt change your job?
pawn Код:
if(!PlayerInfo[playerid][pJob] && PlayerInfo[playerid][pVIPJob] != JOB_MECHANIC) PlayerInfo[playerid][pJob] = JOB_MECHANIC;
                    else if(PlayerInfo[playerid][pVIP] >= 2 && !PlayerInfo[playerid][pVIPJob] && PlayerInfo[playerid][pJob] != JOB_MECHANIC) PlayerInfo[playerid][pVIPJob] = JOB_MECHANIC;
                    SendClientMessage(playerid, COLOR_LIGHTBLUE, "* You have joined the {FF6347}Mechanic {33CCFF}job, type /help to view your job commands.");
Reply
#8

pawn Код:
if(!PlayerInfo[playerid][pJob][0])
{
   format(PlayerInfo[playerid][pJob],128,"JOB_MECHANIC");
     SendClientMessage(playerid, COLOR_LIGHTBLUE, "* You have joined the {FF6347}Mechanic {33CCFF}job, type /help to view your job commands.");
}
That should do the trick,I think..
Reply
#9

Quote:
Originally Posted by Cjgogo
Посмотреть сообщение
That should do the trick,I think..
I feel the need to facepalm .. JOB_MECHANIC is obviously just a numeric define.
Reply
#10

it is a numeric define. whys that? :/
I was being kind of stupid with this post, I just realised something Id done wrong and its all working now.
My bad :/
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)