Menu

Show posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.

Show posts Menu

Messages - Kelvinvenema

#1
Quote from: [ss]keLvin_ on Sep 26, 2020, 10:15 PMyou could do something like this:

playerProfession <- array( GetMaxPlayers(), 0 ); // 0 for no profession.

function getPlayerProfessionName( player )
{
 switch( playerProfession[ player.ID ] )
 {
  case 1:
   return "Police Officer";

  case 2:
   return "Firefighter";

  case 3:
   return "Paramedic";
 }

 return "Citizen";
}

function onPlayerChat( player, message )
{
 Message( format( "[%s] %s: %s", getPlayerProfessionName( player ), player.Name, message ) );

 return 0;
}

function onPlayerPart( player, reason )
{
 playerProfession[ player.ID ] = 0;
}


all you have to do is to assign players a profession anytime using:
playerProfession[ player ID ] = profession ID;
for example:
function onPlayerCommand( player, command, arguments )
{
 if ( command == "cop" )
 {
  playerProfession[ player.ID ] = 1;

  PrivMessage( player, "You are now a Police Officer!" );
 }
}


Your code doesn't seem to work if
error:

AN ERROR HAS OCCURED [the index 'message' does not exist]

CALLSTACK
*FUNCTION [onPlayerChat()] scripts/main.nut line [337]

LOCALS
[text] "32"
[player] INSTANCE
[this] TABLE


and my privatechat for Emergency services doesn't seem to work it doesn't give an error that is pretty weird when I remove the getplayerprofession it works fine but it doesn't show the profession.

MessagePlayer("[#A42F2B][Emergency-Chat] " +getplayerProfession+ " "+player.Name+  ":[#0CF4D4]  " + text + "", plr);
#2
Hello guys I have run into some problems. I recently made a command EmergencyChat for my roleplay server. But the thing is I would like it to show what profession everybody has For example to visualize it:

EmergencyChat: Firefighter: TheKiller01:  "Message"
EmergencyChat: Police: Theweirdguy1:  "Message"
EmergencyChat: Paramedic: Niceman: "Message"

The code down here has something called + "Profession" +
The line with Profession should give the player the string with the Profession that depends on their Job if they are FireFighter the command should output firefighter.

I can't seem to work out how I should do it,
I really appreciate if you could help,

Code:

for( local i = 0; i <= GetMaxPlayers(); i++ )
{
plr = FindPlayer( i );
if ( ( plr ) && ( plr.Skin ==1 || 5 || 6) )
{
MessagePlayer("[#A42F2B][Emergency-Chat] " +Profession+" "+player.Name+  ":[#0CF4D4]  " + text + "", plr);
#3
Hello guys I have run into some problems. I recently made a command EmergencyChat for my roleplay server. But the thing is I would like it to show what profession everybody has For example to visualize it:

EmergencyChat: Firefighter: TheKiller01:  "Message"
EmergencyChat: Police: Theweirdguy1:  "Message"
EmergencyChat: Paramedic: Niceman: "Message"

The code down here has something called + "Profession" +
The line with Profession should give the player the string with the Profession that depends on their Job if they are FireFighter the command should output firefighter.

I can't seem to work out how I should do it,
I really appreciate if you could help,

Code:

for( local i = 0; i <= GetMaxPlayers(); i++ )
{
plr = FindPlayer( i );
if ( ( plr ) && ( plr.Skin ==1 || 5 || 6) )
{
MessagePlayer("[#A42F2B][Emergency-Chat] " +Profession+" "+player.Name+  ":[#0CF4D4]  " + text + "", plr);
#4
Quote from: habi on Feb 12, 2020, 01:46 PMwhich is the line 955 ?
i updated the function

Yes, it is it also doesn't work for you now?
#5
Quote from: habi on Feb 09, 2020, 01:55 PMhey kevin, i tried your code and it showed no errors.

did you mistake O for 0 ?

also next time specify which is the error line.

it could be, but if I type o = 0 in my code and I have no clue how I can change that.
and it could be that you may have some other functions that let your code work differently from mine.
#6
Quote from: habi on Feb 08, 2020, 12:31 PMUse the function like
O(text, "@","$")Again   O(player.Skin, 5,6,7)   if it is player.skin


I appreciate you for helping me, but it still doesn't output the output but it shows some errors this is what I typed pretty simple command.


else if (cmd == "antext")
{
if(O(text, "@","$"))
{
print("no");
}
}

my error is:

AN ERROR HAS OCCURED [attempt to call 'integer']

CALLSTACK
*FUNCTION [onPlayerCommand()] scripts/Command.nut line [955]

LOCALS
[params] NULL
[text] "$"
[cmd] "antext"
[arguments] "$"
[command] "antext"
[player] INSTANCE
[this] TABLE


I tried everything to get it to work changing the name of variables renaming the function completely overdo the function, but nothing seems to work.
can you tell me if I miss another function to get it to work or what did I do wrong?
#7
Quote from: habi on Feb 07, 2020, 02:40 AMfunction O(t,a,...)
{
foreach(val in vargv)
{
if(t==val)return 1;
}
return 0;
}

local t=4;
if(O(t,1,2,3))print("yes");

how could I get it to work in a command it keeps saying that index t doesn't exist or should I make local t = text; ?
#8
Quote from: =RK=MarineForce on Jul 28, 2019, 09:41 PMcan you tell me how can i add spirites and custom mapicons @luis

I may be a bit late, but I could help you with creating custom map icons, first of all, create an icon you like or download your icon you like.
Secondly, you have to put this picture/icon at its destination, the locating is located at /where your server is then, you locate map store, and look for the map with the name mapicons but it in there, and name your icon/picture
 m100_YourIconName.png
the reason why we use 100 because lower than 100 there are already icons. Adding new icons goes from id 100.
after that, you have to create your custom icon in your script if you haven't renamed it should be named main.nut
you create a map icon by using this syntax:

<CreateMarker > // Just the function name
(1, <The world > // by default it is 0
<Vector(),> //  the location where you want it using x, y, and z coordination
1,  < Size > (the size of the picture/icon by default it is mostly 4 or 5)  // trying figuring out which one you need.
RGB <RGB( R, G, B),> // don't be confused about the R, G, B you can find the color is liked on google if you RGB color codes you will probably find it.
100); <mapicon id> // Note less than hundred aren't custom once, those ids already exist use 100 and beyond, don't forget to use the id from your map icon/picture you like those ids numbers should be the same, at the end it should like something like this
CreateMarker(1, Vector( -1438.25,-777.969, 14.8701 ), 1, RGB(216, 241, 0),100);
 I hope this was informative and sorry for the late comment.

#9
Quote from: Athanatos on Feb 05, 2020, 09:07 PMNot really. Functions are the single way to do so. I dont even think any proper language allows you to use if statements like specified. (except JavaScript because it's gay? lol ) And np.

And I think squirreil allows String.Replace(string). Didn't read the documentation. I'll post a link there : <todo insert link , but I want to sleep, posting on forums and game developing at 11:12 PM is nice.>

Yeah, I never looked at Java, because my mainfocus is especially on SQL and squirrel language, so I don't want to learn multiple languages at once.
So am i better of creating dedicated functions?
#10
Quote from: Athanatos on Feb 05, 2020, 06:18 PMYou mean something like strstr(const char*,const char*) in C++?

http://www.cplusplus.com/reference/cstring/strstr/

If you mean checking if the user's text is either 'a' or 'o' use
if((text == "a") || (text == "o")
Explanation: the || is the logic OR operator.

Thanks, for the explanation I appreciate it!
Both are good to know so I could interpret them,
but there isn't any other way to make them smaller expect using functions?
if((text == "a") || (text == "o")
or
if((text == "a") && (text == "o")
 to make them smaller for example:
if (player.Skin == 5 || 6 || 7)
it's pretty clear what it does isn't there a easier to make it smaller?
or else it would probally be pretty painfull for my newsystem, my new system is suppost to filter out characters like. "! || @ || # || $ || % || ^ || & || * || ( || ) " and if I made a lot of (text == "character") it would take me some time to finish it
is there a way to make it if (text == "@ or # or $") or if (text == "@ && # && $)
or isn't that possible
anyways thanks for explaining it so far!
#11
Hello guys sorry to bother you guys again, I really want to know how I can script with using "text"

I still have one question, how could I add multiple strings in text I know how I can use it in if statements, but the same way ain't
working when using text how can I combine this

 if (text == "a") && (text == "o")

how can I combine them to work fine it doesn't work if I do this:

if (text == "a || o ")
// Do function
#12
Quote from: DraGone on Feb 05, 2020, 04:09 AMYou just need to use IsNum() function if you want to check whether the text is a number..

You dont necessarily need to check whether the text is number if you just want to compare two string. You can just do it right away, e.g:
function onPlayerCommand(player, command, text)
{
// Remember, 'text' is a string by default, no matter you typed a number or anything
// Or it is simply null if player left it empty

if ( command == "test" )
{
/* Only proceed if 'text' is not null because we cant compare 'null' with a string */
if ( text != null )
{
/* Compare the 'text' with string '5', notice "5" is a string not integer */
if ( text == "5" ) PrivMessage( player, "You just typed: 5" );
else if ( text == "a" ) PrivMessage( player, "You just typed: a" );
}
}
}

You just need to use IsNum if you really want and need the text to be number, e.g.
function onPlayerCommand(player, command, text)
{
if ( command == "givemecash" )
{
/* Only proceed if 'text' is not null because IsNum function only accept string */
if ( text != null )
{
/* Check whether the 'text' is a number using IsNum function */
/* If it return true, that means the the text is indeed a number */
if ( IsNum( text ) == true )
{
/* Convert 'text' from string to integer. In this example we are going to increase player's cash so it must be integer */
text = text.tointeger( );

/* Compare 'text' with integer 0, we can compare it with integer cuz we already converted it to integer just now */
if ( text <= 0 ) PrivMessage( player, "Hey, the amount must be higher than 0!" );
else
{
player.Cash += text;
PrivMessage( player, "You just got $"+ text +"!" );
}
}
else
{
PrivMessage( player, "Hey, "+ text +" is not a number!" );
}
}
else PrivMessage( player, "Please specify how much you need" );
}
}

The codes above are untested, it's just an example!

Thanks, you now I understand how I can interpret them in my codes and my commands
Using this

local TextSplit = split( text, " " ),let1=TextSplit[ 0 ],num1=TextSplit[ 1 ];

I can name my text whatever I want
for example

  local TextSplit = split( text, " " ),let1=TextSplit[ 0 ],num1=TextSplit[ 1 ];
   if (( let1 == "5") && (num1 == "a")) PrivMessage( player, "You just typed: "+let1+", "+num1+" " );
#13
Quote from: MatheuS on Feb 04, 2020, 05:22 PMif(IsNum == 5) MessagePlayer ("You have typed number 5", player );
if( IsNum("5") ) MessagePlayer( "You have typed number 5", player );
if(Charac == 'a') MessagePlayer("You have typed A",player);
if(text.find( "a" ) != null ) MessagePlayer("You have typed A",player);



I have tried using the if( IsNum("5") ) MessagePlayer( "You have typed number 5", player );
I thought it worked when it pressed the button it outputted the right number but it also sends a message when the number isn't 5 what is wrong with the line it doesn't give me any errors

#14
Quote from: MatheuS on Feb 04, 2020, 05:22 PMif(IsNum == 5) MessagePlayer ("You have typed number 5", player );
if( IsNum("5") ) MessagePlayer( "You have typed number 5", player );
if(Charac == 'a') MessagePlayer("You have typed A",player);
if(text.find( "a" ) != null ) MessagePlayer("You have typed A",player);


I really appreciate your help thanks :)
#15
Quote from: DarkRaZoR^ on Feb 04, 2020, 04:49 PMIt should be...
if( IsNum("5") ) MessagePlayer( "You have typed number 5", player );BTW, where are you running that line?


Where I am running the function:  onPlayerCommand(player, command, arguments)

I was testing something out to specify and return certain values
and it is now working
Thanks :)