Help please
#1

Hello everyone. I want to check if someone's faction name in his file eqauls Los Santos Police Department
I have it like this:

pawn Код:
if(strcmp(PlayerInfo[playerid][pFaction], "Los Santos Police Department", true) != 0)  return SendClientMessage(playerid,COLOR_GREY,"You're not allowed to use this command.");
It just has no effect. What is wrong?
Reply
#2

Okay well that check is seeing if the two strings do not match, I thought you wanted to check if they matched?

Also what are the contents of the variable "PlayerInfo[playerid][pFaction]"?
Reply
#3

Yes that is what I mean. If they do not match it should send the message. And pFaction is defined as:

pFaction[60]; within my PlayerInfo.
It's just saved in the userfile.
It says the name of the faction. That part works correctly.
Reply
#4

Please print the contents of the variable to confirm the data is correctly stored in it.
Reply
#5

Print the contents of PlayerInfo[playerid][pFaction] just before it compares using strcmp and see what the value of the pFaction variable is.

pawn Код:
printf("%s", PlayerInfo[playerid][pFaction]);

Quote:
Originally Posted by JaTochNietDan
Посмотреть сообщение
Okay then you should be checking if the strings match, like so:

pawn Код:
if(strcmp(PlayerInfo[playerid][pFaction], "Los Santos Police Department", true) == 0)
You were originally checking if they didn't match. I suggest you look up the correct usage of strcmp on the SA-MP Wiki.
He stated that he was looking for if the variable didn't match. If the player is not in the police department then he is unable to use this command.
Reply
#6

It just sends a blank messsage : O
Reply
#7

Quote:
Originally Posted by bartje01
Посмотреть сообщение
It just sends a blank messsage : O
There is nothing inside the variable then, make sure you are setting it correctly.
Reply
#8

Quote:
Originally Posted by [HiC]TheKiller
Посмотреть сообщение
Print the contents of PlayerInfo[playerid][pFaction] just before it compares using strcmp and see what the value of the pFaction variable is.

pawn Код:
printf("%s", PlayerInfo[playerid][pFaction]);



He stated that he was looking for if the variable didn't match. If the player is not in the police department then he is unable to use this command.
I mis-read, I noticed when I was reading through it again. Apologies.

Anyway, it seems something is wrong with the data in the variable then, you are not storing the information in the variable correctly.
Reply
#9

Is this correctly?

dini_Set(file, "Faction",PlayerInfo[playerid][pFaction]);
Reply
#10

Quote:
Originally Posted by bartje01
Посмотреть сообщение
Is this correctly?

dini_Set(file, "Faction",PlayerInfo[playerid][pFaction]);
That's setting the information in the file to the value of that variable, what about where you're storing information in the variable in the first place?
Reply


Forum Jump:


Users browsing this thread: 5 Guest(s)