SA-MP Forums

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

Reply
 
Thread Tools Display Modes
Old 11/11/2019, 10:28 AM   #1
davide1999
Little Clucker
 
Join Date: Nov 2019
Posts: 20
Reputation: 0
Default Help onplayertext

Whats wrong in this codes
https://pastebin.com/8uELaUDR
davide1999 is offline   Reply With Quote
Old 11/11/2019, 10:37 AM   #2
Jstylezzz
High-roller
 
Jstylezzz's Avatar
 
Join Date: Sep 2011
Location: Netherlands
Posts: 1,860
Reputation: 1571
Default Re: Help onplayertext

Why do you think anything is wrong in that code? Are you getting errors, crashes or maybe other things? Please elaborate That makes it easier for those that want to help you to pinpoint the issue.
Jstylezzz is offline   Reply With Quote
Old 11/11/2019, 10:38 AM   #3
BizzyD
Gangsta
 
BizzyD's Avatar
 
Join Date: Jan 2011
Location: Home
Posts: 880
Reputation: 66
Default Re: Help onplayertext

It would help if you explained what is wrong, any error?
__________________
We never fail, we only shine with brilliance. One king one faith one religion. And if you hear me come and join the revolution
BizzyD is offline   Reply With Quote
Old 11/11/2019, 10:38 AM   #4
coool
Gangsta
 
coool's Avatar
 
Join Date: Feb 2013
Location: Republic of Pakistan
Posts: 607
Reputation: 54
Default Re: Help onplayertext

What is the problem?
__________________
coool is offline   Reply With Quote
Old 11/11/2019, 10:49 AM   #5
davide1999
Little Clucker
 
Join Date: Nov 2019
Posts: 20
Reputation: 0
Default Re: Help onplayertext

Quote:
Originally Posted by Jstylezzz View Post
Why do you think anything is wrong in that code? Are you getting errors, crashes or maybe other things? Please elaborate That makes it easier for those that want to help you to pinpoint the issue.
if(PlayerInfo[playerid][pAdmin] >= 1 && text[0] == '@')
{
new msg1[128], pName1[MAX_PLAYER_NAME];
GetPlayerName(playerid, pName1, MAX_PLAYER_NAME);
format(msg1, sizeof(msg1), "[ADMIN CHAT] %s (ID %d): %s", pName1, playerid, text[1]);
SendMessageToAdmins(msg1);
return 0;
}

THIS DONT SHOW
davide1999 is offline   Reply With Quote
Old 11/11/2019, 11:41 AM   #6
Mugala
High-roller
 
Mugala's Avatar
 
Join Date: Nov 2012
Location: Georgia, Tbilisi
Posts: 1,161
Reputation: 73
Default Re: Help onplayertext

for first, 128 is not enough, secondly, SendMessageToAdmins is working or not?
__________________
Coding in 8 languages including Pawn, C#, C++ and SQL.
Available for hiring.

If you have a coding question or need an assistance in a code, just PM me.
If you want me to create something for you, here is a Discord Mugala#5651

Currently helping Community members in a coding.
Mugala is offline   Reply With Quote
Old 11/11/2019, 11:42 AM   #7
Jstylezzz
High-roller
 
Jstylezzz's Avatar
 
Join Date: Sep 2011
Location: Netherlands
Posts: 1,860
Reputation: 1571
Default Re: Help onplayertext

Not sure if this is the root cause of the problem, but you should check the execution order of the following part:
Code:
if(PlayerInfo[playerid][pAdmin] >= 1)
{
	new string[128], playername[MAX_PLAYER_NAME];
	GetPlayerName(playerid, playername, sizeof(playername));
	format(string, sizeof(string), "{FF0000}[Admin] {15FF00} %s: {0066CC} %s",playername, text);
	SendClientMessageToAll(0xFF0000C8, string);
	return 0;
}
if(PlayerInfo[playerid][pAdmin] >= 1 && text[0] == '@')
{
		new msg1[128], pName1[MAX_PLAYER_NAME];
		GetPlayerName(playerid, pName1, MAX_PLAYER_NAME);
		format(msg1, sizeof(msg1), "[ADMIN CHAT] %s (ID %d): %s", pName1, playerid, text[1]);
		SendMessageToAdmins(msg1);
		return 0;
}
It will never reach the second if statement because it will return 0 when the player is admin >= 1, which is a condition for the second one too. Try switching them around:
Code:
if(PlayerInfo[playerid][pAdmin] >= 1 && text[0] == '@')
{
		new msg1[128], pName1[MAX_PLAYER_NAME];
		GetPlayerName(playerid, pName1, MAX_PLAYER_NAME);
		format(msg1, sizeof(msg1), "[ADMIN CHAT] %s (ID %d): %s", pName1, playerid, text[1]);
		SendMessageToAdmins(msg1);
		return 0;
}
if(PlayerInfo[playerid][pAdmin] >= 1)
{
	new string[128], playername[MAX_PLAYER_NAME];
	GetPlayerName(playerid, playername, sizeof(playername));
	format(string, sizeof(string), "{FF0000}[Admin] {15FF00} %s: {0066CC} %s",playername, text);
	SendClientMessageToAll(0xFF0000C8, string);
	return 0;
}
Jstylezzz is offline   Reply With Quote
Old 11/11/2019, 12:50 PM   #8
davide1999
Little Clucker
 
Join Date: Nov 2019
Posts: 20
Reputation: 0
Default Re: Help onplayertext

Quote:
Originally Posted by coool View Post
What is the problem?
Quote:
Originally Posted by BizzyD View Post
It would help if you explained what is wrong, any error?
Quote:
Originally Posted by Jstylezzz View Post
Why do you think anything is wrong in that code? Are you getting errors, crashes or maybe other things? Please elaborate That makes it easier for those that want to help you to pinpoint the issue.
Quote:
Originally Posted by Jstylezzz View Post
Not sure if this is the root cause of the problem, but you should check the execution order of the following part:
Code:
if(PlayerInfo[playerid][pAdmin] >= 1)
{
	new string[128], playername[MAX_PLAYER_NAME];
	GetPlayerName(playerid, playername, sizeof(playername));
	format(string, sizeof(string), "{FF0000}[Admin] {15FF00} %s: {0066CC} %s",playername, text);
	SendClientMessageToAll(0xFF0000C8, string);
	return 0;
}
if(PlayerInfo[playerid][pAdmin] >= 1 && text[0] == '@')
{
		new msg1[128], pName1[MAX_PLAYER_NAME];
		GetPlayerName(playerid, pName1, MAX_PLAYER_NAME);
		format(msg1, sizeof(msg1), "[ADMIN CHAT] %s (ID %d): %s", pName1, playerid, text[1]);
		SendMessageToAdmins(msg1);
		return 0;
}
It will never reach the second if statement because it will return 0 when the player is admin >= 1, which is a condition for the second one too. Try switching them around:
Code:
if(PlayerInfo[playerid][pAdmin] >= 1 && text[0] == '@')
{
		new msg1[128], pName1[MAX_PLAYER_NAME];
		GetPlayerName(playerid, pName1, MAX_PLAYER_NAME);
		format(msg1, sizeof(msg1), "[ADMIN CHAT] %s (ID %d): %s", pName1, playerid, text[1]);
		SendMessageToAdmins(msg1);
		return 0;
}
if(PlayerInfo[playerid][pAdmin] >= 1)
{
	new string[128], playername[MAX_PLAYER_NAME];
	GetPlayerName(playerid, playername, sizeof(playername));
	format(string, sizeof(string), "{FF0000}[Admin] {15FF00} %s: {0066CC} %s",playername, text);
	SendClientMessageToAll(0xFF0000C8, string);
	return 0;
}
IT WORK NOW BUT IF IM LOGGED AS RCON IT DONT WORK HOW CAN I DO
davide1999 is offline   Reply With Quote
Old 11/11/2019, 01:06 PM   #9
Jstylezzz
High-roller
 
Jstylezzz's Avatar
 
Join Date: Sep 2011
Location: Netherlands
Posts: 1,860
Reputation: 1571
Default Re: Help onplayertext

That's because RCON is (probably) not connected to your admin system. It can be, but that's something you'd need to add yourself. What you can do to fix the text, is to use IsPlayerAdmin. To make life easier, let's add this into a function:
Code:
//Returns true if the player's admin level is at least 1, or if the player is logged in as RCON.
stock IsPlayerAdminOrRCON(playerid)
{
	return PlayerInfo[playerid][pAdmin] >= 1 || IsPlayerAdmin(playerid);
}
Now all you'd need to do is replace the admin checks with our custom function. Keep in mind that the function only checks if player admin level is at least 1, this function will not take the value of the level into account. In other words, the function does not care whether a player is admin level 1 or level 1337; It will return true either way.

Now you could change
Code:
if(PlayerInfo[playerid][pAdmin] >= 1 && text[0] == '@')
to

Code:
if(IsPlayerAdminOrRCON(playerid) && text[0] == '@')
This can be done for the other if statements that check if the admin level is at least 1 too!
Jstylezzz is offline   Reply With Quote
Old 11/11/2019, 07:06 PM   #10
davide1999
Little Clucker
 
Join Date: Nov 2019
Posts: 20
Reputation: 0
Default Re: Help onplayertext

Quote:
Originally Posted by Jstylezzz View Post
That's because RCON is (probably) not connected to your admin system. It can be, but that's something you'd need to add yourself. What you can do to fix the text, is to use IsPlayerAdmin. To make life easier, let's add this into a function:
Code:
//Returns true if the player's admin level is at least 1, or if the player is logged in as RCON.
stock IsPlayerAdminOrRCON(playerid)
{
	return PlayerInfo[playerid][pAdmin] >= 1 || IsPlayerAdmin(playerid);
}
Now all you'd need to do is replace the admin checks with our custom function. Keep in mind that the function only checks if player admin level is at least 1, this function will not take the value of the level into account. In other words, the function does not care whether a player is admin level 1 or level 1337; It will return true either way.

Now you could change
Code:
if(PlayerInfo[playerid][pAdmin] >= 1 && text[0] == '@')
to

Code:
if(IsPlayerAdminOrRCON(playerid) && text[0] == '@')
This can be done for the other if statements that check if the admin level is at least 1 too!
i put in this order bcs when i type on chtat just send admin chat https://pastebin.com/Xqu3a4S9 but now i cant use admin chat with @
davide1999 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
OnPlayerText HY Scripting Help 4 28/11/2014 06:21 PM
OnPlayerText [rG]Cold Scripting Help 6 17/10/2014 09:54 PM
OnPlayerText hmm Twinki1993 Scripting Help 10 09/01/2012 02:17 AM


All times are GMT. The time now is 07:06 PM.


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