First time scripting
#1

Hello, this is my first scripting experience
im very very noob
i follow this tutorial [ame]http://www.youtube.com/watch?v=4Qe6NbLm5bc[/ame]
i did everything in that video but i got this error when compiling

Код:
D:\Bart\Samp Server\gamemodes\Test Gaemode.pwn(50) : error 001: expected token: "-string end-", but found "-identifier-"
D:\Bart\Samp Server\gamemodes\Test Gaemode.pwn(50) : error 029: invalid expression, assumed zero
D:\Bart\Samp Server\gamemodes\Test Gaemode.pwn(50) : error 029: invalid expression, assumed zero
D:\Bart\Samp Server\gamemodes\Test Gaemode.pwn(50) : fatal error 107: too many error messages on one line

Compilation aborted.Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


4 Errors.
i tried to delete the line 029 but it still giving an error of it
this is the link of my full gamemode http://pastebin.com/zj31yFqR
and please tell me some links that provide a better scripting tutorial. thanks for your help
Reply
#2

Error is at 50 line, not 029, 029 is a error code
Reply
#3

pawn Код:
SendClientMessage(playerid, COLOR_BLACK, "Welcome to test server");
Reply
#4

Quote:
Originally Posted by ikey07
Посмотреть сообщение
Error is at 50 line, not 029, 029 is a error code
lol my epic fail :facepalm:
now i have fixed those but i got this error in this line
Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
	if (strcmp("/test", cmdtext, true, 10) == 0)
	{
		SendClientMessage(playerid, COLOR_BLACK, "[BR]Yahya__");
		SendClientMessage(playerid, COLOR_BLACK, "[BR]Yahya__");
		return 1;
	}
	return 0;
}

public OnPlayerCommandText(playerid, cmdtext[])
{
	if (strcmp("/fix", cmdtext, true, 10) == 0)
	{
		RepairVehicle(vehicleid);
		return 1;
	}
	return 0;
}
it said the "OnPlayerCommandText" symbol is already defined, so i removed the Onplayercommandtext

and become like this
Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
	if (strcmp("/test", cmdtext, true, 10) == 0)
	{
		SendClientMessage(playerid, COLOR_BLACK, "[BR]Yahya__");
		SendClientMessage(playerid, COLOR_BLACK, "[BR]Yahya__");
		return 1;
	}
	return 0;

	{
		RepairVehicle(vehicleid);
		return 1;
	}
	return 0;
}
but i got those errors
Код:
D:\Bart\Samp Server\gamemodes\Test Gaemode.pwn(94) : warning 225: unreachable code
D:\Bart\Samp Server\gamemodes\Test Gaemode.pwn(95) : error 017: undefined symbol "vehicleid"
D:\Bart\Samp Server\gamemodes\Test Gaemode.pwn(98) : warning 225: unreachable code
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


1 Error.
what does the unreacheable code mean, and why the vehicleid is undefined?
thank you before
Reply
#5

Welcome to SA-MP forums, YahyaBR.

It is good that you've done enough research on your own and actually have gotten somewhere. And your script is a lot like with what I started up with 6 years ago. The error line is indeed line 50 in your posted script.

The syntax of SendClientMessage is SendClientMessage(playerid, color, message[]). This means that the first 2 parameters are integers (playerid and color - the second parameter is often used with a HEX representation, though) and the 3rd parameter (message) is supposed to be an array.
A string message such as "Hey!" is actually an array and after you write a message, the [] characters are not required any more.

Please make sure you go through the useful documentation provided at the wiki. Start off with the basics.

// Edit: the problem in the second code is that you have 2 returns in the same code block. Returning means that the callback will stop processing the code. This is probably not what you want.
pawn Код:
if(!strcmp(cmdtext, "/command", true))
{
    // do something here...
}
return true;

// do something else here - but this code will generate a warning about unreachable code as you returned above! And this code won't be reached as the warning suggests.
return false;
Reply
#6

pawn Код:
RepairVehicle(GetPlayerVehicleID(playerid));
And for unreachable code, remove return 0 at test command, and then make the RepairVehicle fix command again.

Or just use my code:

pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
    if (strcmp("/test", cmdtext, true, 10) == 0)
    {
        SendClientMessage(playerid, COLOR_BLACK, "[BR]Yahya__");
        SendClientMessage(playerid, COLOR_BLACK, "[BR]Yahya__");
        return 1;
    }
    if (strcmp("/fix", cmdtext, true, 10) == 0)
    {
        RepairVehicle(GetPlayerVehicleID(playerid));
        return 1;
    }
    return 0;
}
Reply
#7

Quote:
Originally Posted by AndreT
Посмотреть сообщение
Welcome to SA-MP forums, YahyaBR.

It is good that you've done enough research on your own and actually have gotten somewhere. And your script is a lot like with what I started up with 6 years ago. The error line is indeed line 50 in your posted script.

The syntax of SendClientMessage is SendClientMessage(playerid, color, message[]). This means that the first 2 parameters are integers (playerid and color - the second parameter is often used with a HEX representation, though) and the 3rd parameter (message) is supposed to be an array.
A string message such as "Hey!" is actually an array and after you write a message, the [] characters are not required any more.

Please make sure you go through the useful documentation provided at the wiki. Start off with the basics.

// Edit: the problem in the second code is that you have 2 returns in the same code block. Returning means that the callback will stop processing the code. This is probably not what you want.
pawn Код:
if(!strcmp(cmdtext, "/command", true))
{
    // do something here...
}
return true;

// do something else here - but this code will generate a warning about unreachable code as you returned above! And this code won't be reached as the warning suggests.
return false;
Thank you very much for the explanation
but what should i do when im gonna add more command

EDIT:
this one answered my question
Quote:
Originally Posted by SilverKiller
Посмотреть сообщение
pawn Код:
RepairVehicle(GetPlayerVehicleID(playerid));
And for unreachable code, remove return 0 at test command, and then make the RepairVehicle fix command again.

Or just use my code:

pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
    if (strcmp("/test", cmdtext, true, 10) == 0)
    {
        SendClientMessage(playerid, COLOR_BLACK, "[BR]Yahya__");
        SendClientMessage(playerid, COLOR_BLACK, "[BR]Yahya__");
        return 1;
    }
    if (strcmp("/fix", cmdtext, true, 10) == 0)
    {
        RepairVehicle(GetPlayerVehicleID(playerid));
        return 1;
    }
    return 0;
}
thanks for your guys helps
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)