SA-MP Forums Archive
I am new to scripting and need help - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: I am new to scripting and need help (/showthread.php?tid=296578)



I am new to scripting and need help - Dr. Dre - 12.11.2011

Код:
{
	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


Re: I am new to scripting and need help - GangsTa_ - 12.11.2011

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;
    }
}



Re: I am new to scripting and need help - Mr_Scripter - 12.11.2011

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 :/


Re: I am new to scripting and need help - InterRP Team - 12.11.2011

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;
    }
}



Re: I am new to scripting and need help - Michael[NBK] - 12.11.2011

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.


Re: I am new to scripting and need help - Kostas' - 12.11.2011

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


Re: I am new to scripting and need help - Dr. Dre - 12.11.2011

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



Re: I am new to scripting and need help - Kostas' - 12.11.2011

Your Welcome!


Re: I am new to scripting and need help - Dr. Dre - 13.11.2011

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;
}



Re: I am new to scripting and need help - Mr_Scripter - 13.11.2011

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