PDA

View Full Version : I have a coding problem


Mikibey
02/06/2012, 05:58 AM
So basically i followed this tut:
http://www.youtube.com/watch?v=2G3o6Os1n30
and i get this error:
C:\Users\Mihai\Desktop\Galaxy-Games\gamemodes\GGRealLife0.1.pwn(120) : warning 215: expression has no effect
C:\Users\Mihai\Desktop\Galaxy-Games\gamemodes\GGRealLife0.1.pwn(343) : error 001: expected token: "-identifier-", but found "("
Pawn compiler 3.2.3664 Copyright (c) 1997-2006, ITB CompuPhase


1 Error.


here is my code...i cannot find what is wrong....everything should work....:mad: please can u help me?

#include <a_samp>
#include <dini>
#include <dudb>
#include <file>

#pragma unused ret_memcpy

#define COLOR_YELLOW 0xFFFF00
#define COLOR_RED 0xFF0000
#define ReadPlayer
#define Spawn
#define WritePlayer

#define SERVER_USER_FILE "administration/%s.ini"

enum pInfo
{
pAdminLevel,
pCash,
pScore,
}

new PlayerInfo[MAX_PLAYERS][pInfo];
new gPlayerLogged[MAX_PLAYERS];
new bool:newPlayer = false;

main()
{
print("\n----------------------------------");
print(" GG-RealLife 0.1");
print("----------------------------------\n");
}

public OnGameModeInit()
{
SetGameModeText("GG-RealLife 0.1");
AddPlayerClass(0,1481.3665,-1759.4100,17.5313,2.9740,0,0,0,0,0,0);
//Masini Los Santos (cristi)
AddStaticVehicle(402,1363.1136,-1300.6017,13.2846,181.8885,13,13);
AddStaticVehicle(405,1329.5442,-1369.1112,13.5429,268.5680,24,1);
AddStaticVehicle(412,1085.3099,-1366.2987,13.5083,359.8742,64,1);
AddStaticVehicle(424,951.2397,-1364.3125,13.2168,92.9506,88,64);
AddStaticVehicle(426,965.5166,-1369.2640,13.2127,270.9866,88,64);
AddStaticVehicle(445,676.1548,-1428.2697,14.7267,0.0399,88,64);
AddStaticVehicle(458,1460.3394,-1506.6311,13.4155,89.3990,88,64);
AddStaticVehicle(466,1507.6152,-1750.6693,13.2740,358.9849,123,1);
AddStaticVehicle(467,1535.9390,-1672.0173,13.1099,359.4517,123,1);
AddStaticVehicle(479,1282.4524,-1522.9989,13.2908,270.2958,123,1);
AddStaticVehicle(489,1920.7021,-1790.3239,13.1119,269.2996,123,1);
AddStaticVehicle(496,1946.6371,-2123.7000,13.2749,89.5041,123,1);
AddStaticVehicle(499,1776.9808,-1887.3065,13.1141,88.2713,112,1);
AddStaticVehicle(517,1775.9952,-1932.7899,13.1131,175.6704,112,1);
AddStaticVehicle(529,1805.3340,-1932.5547,13.1135,0.7090,112,1);
AddStaticVehicle(604,1674.8048,-1125.0746,23.6333,267.5852,112,1);
AddStaticVehicle(605,1685.7198,-1044.8259,23.6333,358.9815,112,1);
AddStaticVehicle(425,1761.6339,-1046.5703,23.6880,359.6237,112,1);
AddStaticVehicle(412,1651.7705,-1018.0209,23.6255,9.5531,112,1);
AddStaticVehicle(481,1592.7891,-1057.7676,23.6333,129.2202,112,1);
AddStaticVehicle(521,1328.0367,-1061.3395,28.6363,1.8183,112,1);
AddStaticVehicle(600,1027.6488,-1052.6136,31.3748,177.2368,112,1);
AddStaticVehicle(531,1066.8021,-876.1398,42.9531,85.8525,112,1);
AddStaticVehicle(579,1065.7228,-902.9531,42.8549,264.3694,112,1);
AddStaticVehicle(554,1706.7697,-1879.4489,13.4003,357.7852,13,13);
AddStaticVehicle(549,1618.3584,-1559.6875,14.0050,87.9495,13,13);
AddStaticVehicle(566,1549.5625,-2211.9944,13.3864,179.6881,13,13);
AddStaticVehicle(579,297.8336,-1366.4697,13.9333,22.6049,13,13);
AddStaticVehicle(554,442.9940,-1738.1919,9.2225,179.3603,13,13);
AddStaticVehicle(479,823.4073,-2028.5421,12.6989,268.6736,13,13);
AddStaticVehicle(412,824.0782,-1915.5522,12.6989,88.9128,13,13);
AddStaticVehicle(418,1062.5624,-1737.5902,13.3109,90.1607,13,13);
//Masini Los Santos Sfarsit
return 1;
}

public OnGameModeExit()
{
return 1;
}

public OnPlayerConnect(playerid)
{
gPlayerLogged[playerid] = 0;
new name[MAX_PLAYER_NAME], file[256];
GetPlayerName(playerid, name, sizeof(name));
format(file, sizeof(file), SERVER_USER_FILE, name);
if (!dini_Exists(file))
{
ShowPlayerDialog(playerid, 1, DIALOG_STYLE_PASSWORD, "Hello There! You are not registered.", "Please input a password below to create an account...", "Register", "Leave");
}
if(fexist(file))
{
ShowPlayerDialog(playerid, 2, DIALOG_STYLE_PASSWORD, "Hello There! You are registered.", "Please input your password below to login to your account...", "Login", "Leave");
newPlayer = true;
}
return 1;
}

public OnPlayerDisconnect(playerid, reason)
{

new name[MAX_PLAYER_NAME], file[256];
GetPlayerName(playerid, name, sizeof(name));
format(file, sizeof(file), SERVER_USER_FILE, name);
if(gPlayerLogged[playerid] == 1)
{
dini_IntSet(file, "Score", PlayerInfo[playerid][pScore]);
dini_IntSet(file, "Money", PlayerInfo[playerid][pCash]);
dini_IntSet(file, "AdminLevel",PlayerInfo[playerid][pAdminLevel]);
}
gPlayerLogged[playerid] = 0;
return 1;
}

public OnPlayerSpawn(playerid)
{
if(newPlayer)
{
new skin[4];
valstr(skin,GetPlayerSkin(playerid));
WritePlayer(skin,playerid,false);
}
}
public OnPlayerDeath(playerid, killerid, reason)
{
return 1;
}

public OnPlayerRequestSpawn(playerid)
{
return 1;
}

public OnVehicleSpawn(vehicleid)
{
return 1;
}

public OnVehicleDeath(vehicleid, killerid)
{
return 1;
}

public OnPlayerText(playerid, text[])
{
return 1;
}

public OnPlayerCommandText(playerid, cmdtext[])
{
if (strcmp("/mycommand", cmdtext, true, 10) == 0)
{
// Do something here
return 1;
}
return 0;
}

public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
return 1;
}

public OnPlayerExitVehicle(playerid, vehicleid)
{
return 1;
}

public OnPlayerStateChange(playerid, newstate, oldstate)
{
return 1;
}

public OnPlayerEnterCheckpoint(playerid)
{
return 1;
}

public OnPlayerLeaveCheckpoint(playerid)
{
return 1;
}

public OnPlayerEnterRaceCheckpoint(playerid)
{
return 1;
}

public OnPlayerLeaveRaceCheckpoint(playerid)
{
return 1;
}

public OnRconCommand(cmd[])
{
return 1;
}

public OnObjectMoved(objectid)
{
return 1;
}

public OnPlayerObjectMoved(playerid, objectid)
{
return 1;
}

public OnPlayerPickUpPickup(playerid, pickupid)
{
return 1;
}

public OnVehicleMod(playerid, vehicleid, componentid)
{
return 1;
}

public OnVehiclePaintjob(playerid, vehicleid, paintjobid)
{
return 1;
}

public OnVehicleRespray(playerid, vehicleid, color1, color2)
{
return 1;
}

public OnPlayerSelectedMenuRow(playerid, row)
{
return 1;
}

public OnPlayerExitedMenu(playerid)
{
return 1;
}

public OnPlayerInteriorChange(playerid, newinteriorid, oldinteriorid)
{
return 1;
}

public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
return 1;
}

public OnRconLoginAttempt(ip[], password[], success)
{
return 1;
}

public OnPlayerUpdate(playerid)
{
return 1;
}

public OnPlayerStreamIn(playerid, forplayerid)
{
return 1;
}

public OnPlayerStreamOut(playerid, forplayerid)
{
return 1;
}

public OnVehicleStreamIn(vehicleid, forplayerid)
{
return 1;
}

public OnVehicleStreamOut(vehicleid, forplayerid)
{
return 1;
}

public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
if (dialogid == 1)
{
new name[MAX_PLAYER_NAME], file[256], string[128];
GetPlayerName(playerid, name, sizeof(name));
format(file, sizeof(file), SERVER_USER_FILE, name);
if(!response) return Kick(playerid);
if (!strlen(inputtext)) return
ShowPlayerDialog(playerid, 1, DIALOG_STYLE_INPUT, "Hello There! You are not registered.", "Please input a password below to create an account...", "Register", "Leave");
dini_Create(file);
dini_IntSet(file, "Password", udb_hash(inputtext));
dini_IntSet(file, "AdminLevel",PlayerInfo[playerid][pAdminLevel] = 0);
dini_IntSet(file, "Money",PlayerInfo[playerid][pCash] = 500);
dini_IntSet(file, "Score",PlayerInfo[playerid][pScore] = 0);
format(string, 128, "[SYSTEM]: You succesfully registered the nickname %s with password %s, you have been auto logged in.", name, inputtext);
SendClientMessage(playerid, COLOR_YELLOW, string);
gPlayerLogged[playerid] = 1;
}
else if (dialogid == 2)
{
new name[MAX_PLAYER_NAME], file[256];
GetPlayerName(playerid, name, sizeof(name));
format(file, sizeof(file), SERVER_USER_FILE, name);
if(!response) return Kick(playerid);
if (!strlen(inputtext)) return ShowPlayerDialog(playerid, 2, DIALOG_STYLE_INPUT, "Hi your registered", "Your registered. Input your pw below", "Login", "Leave");
new tmp;
tmp = dini_Int(file, "Password");
if(udb_hash(inputtext) != tmp)
{
SendClientMessage(playerid, COLOR_RED, "Wrong PW sir.");
ShowPlayerDialog(playerid, 2, DIALOG_STYLE_INPUT, "Hello There! You are registered.", "Please input your password below to login to your account...", "Login", "Leave");
}
else
{
gPlayerLogged[playerid] = 1;
PlayerInfo[playerid][pAdminLevel] = dini_Int(file, "AdminLevel");
SetPlayerScore(playerid, PlayerInfo[playerid][pScore]);
GivePlayerMoney(playerid, dini_Int(file, "Money")-GetPlayerMoney(playerid));
SendClientMessage(playerid,COLOR_RED, "[SYSTEM]: Successfully logged in!");
}
}
return 1;
}

public OnPlayerClickPlayer(playerid, clickedplayerid, source)
{
return 1;
}

public OnPlayerRequestClass(playerid, classid)
{
if (newPlayer)
{
SetPlayerPos(playerid, 1544.7887,-1675.4630,13.5591);
SetPlayerFacingAngle(playerid, 90.0);
SetPlayerCameraPos(playerid, 1541.5293,-1675.4012,13.5527);
SetPlayerCameraLookAt(playerid, 1544.7887,-1675.4630,13.5591);
}
else
{
SetTimerEx("Spawn",1,false,"i",playerid);
}
}

public Spawn(playerid)
{
SpawnPlayer(playerid);
SetPlayerSkin(playerid, strval(ReadPlayer(2,playerid)));
}

Scott
02/06/2012, 06:05 AM
Your problem is because you are defining the following macros:

#define Spawn
#define WritePlayer

But nothing is assigned to them. It looks like you can just remove #define Spawn to solve one of the errors, but it looks like something should be assigned to Writeplayer. See the following wiki article for more info about #define: http://wiki.sa-mp.com/wiki/Keywords:Directives#.23define

ReneG
02/06/2012, 06:09 AM
On the code below....
if(newPlayer)
{
new skin[4];
valstr(skin,GetPlayerSkin(playerid));
WritePlayer(skin,playerid,false); // line 120
}
WritePlayer is defined at the top as
#define WritePlayer
Which has no value, or is not a valid function. You might want to re-do the tutorial.

The same thing is with line 343, the "Spawn" function is defined as zero.

EDIT:


Toooooooooooooooo late....

Mikibey
02/06/2012, 06:21 AM
Your problem is because you are defining the following macros:

#define Spawn
#define WritePlayer

But nothing is assigned to them. It looks like you can just remove #define Spawn to solve one of the errors, but it looks like something should be assigned to Writeplayer. See the following wiki article for more info about #define: http://wiki.sa-mp.com/wiki/Keywords:Directives#.23define

i did this and now i get this error:
C:\Users\Mihai\Desktop\Galaxy-Games\gamemodes\GGRealLife0.1.pwn(119) : error 017: undefined symbol "WritePlayer"
C:\Users\Mihai\Desktop\Galaxy-Games\gamemodes\GGRealLife0.1.pwn(342) : warning 235: public function lacks forward declaration (symbol "Spawn")
C:\Users\Mihai\Desktop\Galaxy-Games\gamemodes\GGRealLife0.1.pwn(345) : error 035: argument type mismatch (argument 1)
Pawn compiler 3.2.3664 Copyright (c) 1997-2006, ITB CompuPhase



EDIT: i fixed one of the errors now i only have:
C:\Users\Mihai\Desktop\Galaxy-Games\gamemodes\GGRealLife0.1.pwn(119) : warning 215: expression has no effect
C:\Users\Mihai\Desktop\Galaxy-Games\gamemodes\GGRealLife0.1.pwn(342) : warning 235: public function lacks forward declaration (symbol "Spawn")
C:\Users\Mihai\Desktop\Galaxy-Games\gamemodes\GGRealLife0.1.pwn(345) : error 035: argument type mismatch (argument 1)
Pawn compiler 3.2.3664 Copyright (c) 1997-2006, ITB CompuPhase


1 Error.

Niko_boy
02/06/2012, 08:44 AM
do
forward Spawn(..); // here " .. " is the var's u want in callback
Show us callback public Spawn // line 342
and lines 345