I Need Help - 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)
+--- Thread: I Need Help (
/showthread.php?tid=296550)
I Need Help -
Cody_Maverak - 12.11.2011
Hello! I am new to PAWNO scripting and need help with my admin script.
The code is:
The last if statement should compare the two variables and carry out actions if the conditionals are true or false. But it does not do this! Can someone help?
Also, I have a pickup that gives a player a minigun. However when you pick it up, you get kicked. Can someone help with this too? [SOLVED by Chrillzen!]
Thanks,
Cody_Maverak
Re: I Need Help -
Chrillzen - 12.11.2011
You have a function in your script that kicks everybody with Miniguns, probably under OnPlayerUpdate.
Re: I Need Help -
Cody_Maverak - 12.11.2011
Okay thank you Chrillzen. I did in fact have that in my game mode :P
Re: I Need Help -
Rachael - 12.11.2011
Here is the problem
pawn Код:
if (Password[] == actualPassword[])
The only time you use [] is if/when the variable is a string function parameter, or being defined as an array like this ( for example )
pawn Код:
stock YourFunction( playerid , inputtext[] )
//or
new brown[] = { 34 , 45 , 0 , 6 };
You are trying to compare the password with the players input, so you could use strcmp
pawn Код:
if( !strcmp( params , actualpassword , true ) )
another issue involving the command processor. Empty param strings will not trigger strlen, so the author has included a function to detect a lack of input from the player
pawn Код:
if( !strlen(params) )
//should be
if( isnull(params) )
Also, another small issue, you have an input string 256 long, the maximum number of characters in the chatbox is around 128.
anyway good luck.
Re: I Need Help -
Michael[NBK] - 12.11.2011
Quote:
Originally Posted by Rachael
Here is the problem
pawn Код:
if (Password[] == actualPassword[])
The only time you use [] is if/when the variable is a string function parameter, or being defined as an array like this ( for example )
pawn Код:
stock YourFunction( playerid , inputtext[] )
//or
new brown[] = { 34 , 45 , 0 , 6 };
You are trying to compare the password with the players input, so you could use strcmp
pawn Код:
if( !strcmp( params , actualpassword , true ) )
another issue involving the command processor. Empty param strings will not trigger strlen, so the author has included a function to detect a lack of input from the player
pawn Код:
if( !strlen(params) )
//should be
if( isnull(params) )
Also, another small issue, you have an input string 256 long, the maximum number of characters in the chatbox is around 128.
anyway good luck.
|
Is isnull already defined? Or how to define it?
Thanks in advance
Re: I Need Help -
Rachael - 12.11.2011
sorry, disregard that part of my previous post, I thought you were using zcmd.
You should be able to see if strlen works with dcmd.
Re: I Need Help -
Cody_Maverak - 12.11.2011
But doesn't this already check if it is empty or not:
Код:
if(!strlen(params)) return SendClientMessage(playerid, COLOR_YELLOW, "Usage: /login [Password]");
Anyway, Racheal, you were right with the strcmp. It works!