Help please - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (
https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Help please (
/showthread.php?tid=265516)
Help please -
bartje01 - 01.07.2011
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?
Re: Help please -
JaTochNietDan - 01.07.2011
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]"?
Re: Help please -
bartje01 - 01.07.2011
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.
Re: Help please -
JaTochNietDan - 01.07.2011
Please print the contents of the variable to confirm the data is correctly stored in it.
Re: Help please -
[HiC]TheKiller - 01.07.2011
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.
Re: Help please -
bartje01 - 01.07.2011
It just sends a blank messsage : O
Re: Help please -
[HiC]TheKiller - 01.07.2011
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.
Re: Help please -
JaTochNietDan - 01.07.2011
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.
Re: Help please -
bartje01 - 01.07.2011
Is this correctly?
dini_Set(file, "Faction",PlayerInfo[playerid][pFaction]);
Re: Help please -
JaTochNietDan - 01.07.2011
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?