SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help

Reply
 
Thread Tools Display Modes
Old 22/05/2013, 08:57 PM   #1
HurtLocker
Gangsta
 
HurtLocker's Avatar
 
Join Date: Dec 2012
Location: Hellas, Thessaloniki
Posts: 570
Reputation: 29
Default how to compare string cell to character?

I want to make this check (detect if player enters command):
pawn Code:
if(text[0]=='/')
I tried exactly the code above, gets compiled but has no effect.
__________________
Join Fallout's Best TDM server ever!
Useful command: Sounds finder
Turotial: Making a textdraw without editors
HurtLocker is offline   Reply With Quote
Old 22/05/2013, 09:00 PM   #2
Richie©
Banned
 
Join Date: Feb 2012
Location: Norway
Posts: 392
Reputation: 53
Default Re: how to compare string cell to character?

You can use strfind for that.
http://wiki.sa-mp.com/wiki/Strfind
Richie© is offline   Reply With Quote
Old 22/05/2013, 09:04 PM   #3
Y_Less
Beta Tester
 
Y_Less's Avatar
 
Join Date: Jun 2008
Location: 629 - git.io/Y
Posts: 15,234
Reputation: 3183
Default Re: how to compare string cell to character?

OK, that check DOES work - but by the looks of it you are trying to do this in "OnPlayerText", which doesn't get called for commands (because they're not text).
Y_Less is offline   Reply With Quote
Old 22/05/2013, 09:04 PM   #4
HurtLocker
Gangsta
 
HurtLocker's Avatar
 
Join Date: Dec 2012
Location: Hellas, Thessaloniki
Posts: 570
Reputation: 29
Default AW: how to compare string cell to character?

Quote:
Originally Posted by Richie© View Post
You can use strfind for that.
http://wiki.sa-mp.com/wiki/Strfind
This is not what I asked. Title is pretty clear I think.

y_less: Yes, I used it under onplayertext. Now what?
EDIT: I go test it under OnPlayerCommandText

EDIT: damn, same thing. What can I do now?
__________________
Join Fallout's Best TDM server ever!
Useful command: Sounds finder
Turotial: Making a textdraw without editors
HurtLocker is offline   Reply With Quote
Old 22/05/2013, 09:35 PM   #5
Vince
Spam Machine
 
Vince's Avatar
 
Join Date: Sep 2007
Location: Belgium
Posts: 10,964
Reputation: 2649
Default Re: how to compare string cell to character?

OnPlayerCommandText gets called for every input that starts with a forward slash. What is so hard to understand about that?
__________________
Vince is offline   Reply With Quote
Old 22/05/2013, 09:41 PM   #6
HurtLocker
Gangsta
 
HurtLocker's Avatar
 
Join Date: Dec 2012
Location: Hellas, Thessaloniki
Posts: 570
Reputation: 29
Default AW: how to compare string cell to character?

Ok I did this:
pawn Code:
public OnPlayerCommandText(playerid, cmdtext[])
{
if (Jailed[playerid]==true) return SendClientMessage(playerid, 0xFF0000AA, "blabla");
return 0;
}
doesn't work
__________________
Join Fallout's Best TDM server ever!
Useful command: Sounds finder
Turotial: Making a textdraw without editors
HurtLocker is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
String and number compare. budelis Scripting Help 5 30/08/2012 11:53 AM
Compare two string Kyra Scripting Help 9 21/07/2012 03:30 AM
compare empty String reini90 Server Support 3 14/03/2012 02:15 PM
compare string ombre Scripting Help 10 19/11/2011 05:50 PM
<<>> Compare STRING Ricop522 Help Archive 0 24/06/2011 01:09 AM


All times are GMT. The time now is 09:09 AM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.