Help please
#1

Hello everyone.
I made this command :
Код HTML:
if(strcmp("/tower",cmdtext,true) == 0)
    {
    if(IsPlayerAdmin(playerid)) return 0;
    SetPlayerPos(playerid,1543.8469,-1353.4261,329.4741);
    SetPlayerVirtualWorld(playerid, 5)
    ResetPlayerWeapons(playerid);
    GivePlayerWeapon(playerid, 46);
    SetPlayerHealth(playerid, 100);
    SetPlayerArmour(playerid, 100);
    return 1;
    }
But when i entered the server to use it, Before i login to my RCON, I typed /tower.
Then my position changed and my world changed too.

But, I want the command to work only if i'm logged in RCON.
Can you tell me what to do or what is the wrong in this command?
Reply
#2

As I posted in your thread that was in the wrong section:

pawn Код:
if(strcmp("/tower",cmdtext,true) == 0)
{
    if (!IsPlayerAdmin(playerid)) return 0;
    SetPlayerPos(playerid,1543.8469,-1353.4261,329.4741);
    SetPlayerVirtualWorld(playerid, 5)
    ResetPlayerWeapons(playerid);
    GivePlayerWeapon(playerid, 46);
    SetPlayerHealth(playerid, 100);
    SetPlayerArmour(playerid, 100);
    return 1;
}
The '!' in 'if (!IsPlayerAdmin(playerid)) return 0;' means 'not', so if player is not admin, return 0. You could also return a message such as 'return SendClientMessage(playerid, -1, "Access denied");

https://sampwiki.blast.hk/wiki/Control_Structures
Reply
#3

Quote:
Originally Posted by rymax99
Посмотреть сообщение
As I posted in your thread that was in the wrong section:

pawn Код:
if(strcmp("/tower",cmdtext,true) == 0)
{
    if (!IsPlayerAdmin(playerid)) return 0;
    SetPlayerPos(playerid,1543.8469,-1353.4261,329.4741);
    SetPlayerVirtualWorld(playerid, 5)
    ResetPlayerWeapons(playerid);
    GivePlayerWeapon(playerid, 46);
    SetPlayerHealth(playerid, 100);
    SetPlayerArmour(playerid, 100);
    return 1;
}
The '!' in 'if (!IsPlayerAdmin(playerid)) return 0;' means 'not', so if player is not admin, return 0. You could also return a message such as 'return SendClientMessage(playerid, -1, "Access denied");

https://sampwiki.blast.hk/wiki/Control_Structures
Thank you very much.
Resolved.

Other question :
I don't know what is my scripting language name :P but it's "if(strcmp..." and others.
Can you tell me in my scripting language how to change "SERVER: Unknown Command" to something else ?
Reply
#4

Anyone answer please ?
When i type wrong command, The system types "SERVER: Unknown command", How to change "SERVER: Unknown command" to other message ?
Reply
#5

You're using OnPlayerCommandText(playerid, cmdtext[])
So just replace return 0; at the end with "SendClientMessage(playerid, your color, "your message");"

But if you change to zcmd, delete all OnPlayerCommandText and add this to the script.
pawn Код:
public OnPlayerCommandPerformed(playerid, cmdtext[], success)
{
    if (!success)
        return SendClientMessage(playerid, your color, "your message");

    return 1;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)