Hi guys. Today, i am successfully able to add skins into my server. And I was thinking to add 2 types of announce message in the server:
1. Welcome to the server
2. To add an announce message that displays Skin class/name when we are selecting our own skin.
Actually, I was able to do both things in the server but since then, it is not displaying my other skins!!! It keep showing only one skin i.e cop skin and i announce messages to my other skin also. Here is the code that i created:
function onPlayerRequestClass( player, classID, team, skin )
{
if ( stats[ player.ID ].ASpawn ) player.Spawn();
if ( player.Skin = 1 );
{
Announce( "Cop", player, 1 );
return 1;
}
if ( player.Skin = 2 );
{
Announce( "SWAT", player, 1 );
return 1;
}
}
Please help me. I am a newbie scripter and i don't know lots of stuffs about coding!!! :-[
(player.Skin = 1) it should be (player.Skin == 1) "==" this is equals operator. [ Relational ]
"==" by using this you are comparing the player skin with ID you gave. "=" this assigns values,its wrong.
Add your welcome Message onPlayerJoin(player), to display skin name you are doing right just use "==" in place of "="
Thanks, Jayant for helping me!!! :) This works but there is a problem :'( It is not showing SWAT Announce message when i browse/navigate to SWAT skin!!!
function onPlayerRequestClass( player, classID, team, skin )
{
if ( stats[ player.ID ].ASpawn ) { player.Spawn(); }
if ( player.skin == 1 )
{
Announce( "Cop", player, 1 );
}
else if ( player.skin == 2 )
{
Announce( "SWAT", player, 1 );
}
}
You must use the parameters of the event or you can use a local variable,Like,
local var = player.Skin; // var is a local variable which will now hold skin values
if( var == 2 ) { Announce("Skin 2",player,1); }
else if( var == 1 ) { Announce("Skin 1",player,1); }
Other way you can use team id too to display team name for all skins.
Last Edit - Now fine..I just messed up things in my post.
Quote from: jayant on Mar 12, 2016, 01:53 PMfunction onPlayerRequestClass( player, classID, team, skin )
{
if ( stats[ player.ID ].ASpawn ) { player.Spawn(); }
if ( player.skin == 1 )
{
Announce( "Cop", player, 1 );
}
else if ( player.skin == 2 )
{
Announce( "SWAT", player, 1 );
}
}
You must use the parameters of the event or you can use a local variable,Like,
local var = player.Skin; // var is a local variable which will now hold skin values
if( var == 2 ) { Announce("Skin 2",player,1); }
else if( var == 1 ) { Announce("Skin 1",player,1); }
Other way you can use team id too to display team name for all skins.
Last Edit - Now fine..I just messed up things in my post.
I guess not brother, It is not working!!! After removing semicolons and adding "==" in the code, it is now showing SWAT on every skin instead of Cop :(. Dude i guess you know what i am trying to do is there any other way to announce skin message while navigating skins??? if there is not, help me man please!!!
While navigating you only do the below,which I already done above with a mistake [ And you not pointed out :p ]
function onPlayerRequestClass( player, classID, team, skin )
{
if ( stats[ player.ID ].ASpawn ) { player.Spawn(); }
if ( skin == 1 ) { Announce( "Cop", player, 1 ); }
else if ( skin == 2 ) { Announce( "Swat", player, 1 ); }
}
Use ^^
If you get errors,post it with console image and line of the code.I think it was my mistake..The above should work fine.
Now it is working. Thanks jayant brother :) . This is your great help!!!
Topic Locked