I am new to scripting and need help
#1

Код:
{
	if (strcmp("/armour", cmdtext, true, 10) == 0)
	{
	    SetPlayerArmour(playerid, 100);
	    SendClientMessage(playerid, COLOR_BRIGHTRED, "Armour set to 100");
	}
	return 1;
	if (strcmp("/spawn", cmdtext, true, 10) == 0)
	{
		SetPlayerPos(playerid, 1958.3783, 1343.1572, 15.3746);
		SendClientMessage(playerid, COLOR_YELLOW, "Teleported to spawn");
	}
	return 1;
}
Okay thats what I did and now I get (125) : warning 225: unreachable code
Line 125 is the if (strcmp("/armour", cmdtext, true, 10) == 0)

Its a pretty basic script.

I just want to know what the numbers mean in 10) == 0) and what return 1 actually does so I can fix my script. If its got nothing to do with that then just tell me
Reply
#2

Try:

pawn Код:
{
    if (strcmp(cmdtext,"/armour", true, 10) == 0)
    {
        SetPlayerArmour(playerid, 100);
        SendClientMessage(playerid, COLOR_BRIGHTRED, "Armour set to 100");
        return 1;
    }
    if (strcmp(cmdtext,"/spawn", true, 10) == 0)
    {
        SetPlayerPos(playerid, 1958.3783, 1343.1572, 15.3746);
        SendClientMessage(playerid, COLOR_YELLOW, "Teleported to spawn");
        return 1;
    }
}
Reply
#3

it gives me no error
pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
    if (strcmp("/armour", cmdtext, true, 10) == 0)
    SetPlayerArmour(playerid,100);
    return 1;

    if (strcmp("/spawn", cmdtext, true, 10) == 0)
    {
    SetPlayerPos(playerid, 1958.3783, 1343.1572, 15.3746);
    SendClientMessage(playerid, COLOR_YELLOW, "Teleported to spawn");
    }
    return 1;
}
Edit: Late :/
Reply
#4

pawn Код:
{
    if (strcmp("/armour", cmdtext, true) == 0)
    {
        SetPlayerArmour(playerid, 100);
        SendClientMessage(playerid, COLOR_BRIGHTRED, "Armour set to 100");
            return 1;
    }
    if (strcmp("/spawn", cmdtext, true) == 0)
    {
                SpawnPlayer(playerid);
        SetPlayerPos(playerid, 1958.3783, 1343.1572, 15.3746);
        SendClientMessage(playerid, COLOR_YELLOW, "Teleported to spawn");
                return 1;
    }
}
Reply
#5

pawn Код:
CMD:armour(playerid,parmas[])
{
    SetPlayerArmour(playerid,100);
    SendClientMessage(playerid,COLOR_LIGHTRED,"Armour set to 100");
    return 1;
}
CMD:spawn(playerid,params[])
{
    SetPlayerPos(playerid,1958.3783, 1343.1572, 15.3746);
    SendClientMessage(playerid,COLOR_LIGHTBLUE, "Teleported to spawn");
    return 1;
}
Try using ZCMD it is alot easier and quicker and alot better to use if you are new to scripting, Best of luck with scripting buddy. If you become stuck there are always people on here who will be happy to help.
Reply
#6

Quote:
Originally Posted by Mr_Scripter
Посмотреть сообщение
it gives me no error
pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
    if (strcmp("/armour", cmdtext, true, 10) == 0)
        SetPlayerArmour(playerid,100);

    if (strcmp("/spawn", cmdtext, true, 10) == 0)
    {
    SetPlayerPos(playerid, 1958.3783, 1343.1572, 15.3746);
    SendClientMessage(playerid, COLOR_YELLOW, "Teleported to spawn");
    }
    return 1;
}
Edit: Late :/
Why you didn't return 1; at the armour?

Anyway I will agree with Michael[NBK] , ZCMD is easier/faster and best for me!
May this tutorial help you [Tutorial] How to create commands with ZCMD & sscanf
Reply
#7

Thanks for your help I appreciate it...
I will try and use ZCMD.
Reply
#8

Your Welcome!
Reply
#9

Just some additional help... How do I fix this:
(120) : error 029: invalid expression, assumed zero

I modified your Armour command but its still got to do with the actual defining of the command...

Код:
CMD:armour(playerid, params[])
{
    new targetid;
    if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, 0xFFFFFFF,"Error: This command is only for RCON Admins");
    if(sscanf(params,"u", targetid)) return SendClientMessage(playerid, 0xFFFFFFF,"Syntax error.Correct usage: /armour [PlayerID]");
    if(!IsPlayerConnected(targetid)) return SendClientMessage(playerid, 0xFFFFFFF,"That player is not connected to the server!");
    SetPlayerArmour(targetid, 100);
    return 1;
}
Reply
#10

Quote:
Originally Posted by Kostas'
Посмотреть сообщение
Why you didn't return 1; at the armour?

Anyway I will agree with Michael[NBK] , ZCMD is easier/faster and best for me!
May this tutorial help you [Tutorial] How to create commands with ZCMD & sscanf
Oopps i forgot.. Thanks for telling me
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)