PDA

View Full Version : Abit help please


MarTaTa
18/09/2012, 09:12 AM
Hello there,
so I made my first dynamic system for small events. But I got problems with it. After I compiled it, everything seems good, no errors / warnings. Here's the code :


#define MAX_EVENT_POINTS 4
Defined max event points,


new ePointCount;
The point count


enum EventData
{
Float: ePosX,
Float: ePosY,
Float: ePosZ,
eVW,
eInterior,
Text3D: eText,
eCapturePlace
}
new EventInfo[MAX_EVENT_POINTS][EventData];

The enumeration and here are the commands ->


command(createpoint, playerid, params[])
{
if(Player[playerid][AdminLevel] >= 2)
{
new text[30], string[128], id = ePointCount;
if(sscanf(params, "s", text)) return SendClientMessage(playerid, WHITE, "SYNTAX: /createpoint [text]");
new Float:x, Float:y, Float:z;
GetPlayerPos(playerid, x, y, z);
EventInfo[id][ePosX] = x;
EventInfo[id][ePosY] = y;
EventInfo[id][ePosZ] = z;
EventInfo[id][eVW] = GetPlayerVirtualWorld(playerid);
EventInfo[id][eInterior] = GetPlayerInterior(playerid);
format(string, sizeof(string), "*Capture Point ID %d created at PosX(%d), PosY(%d), PosZ(%d)", ePointCount, EventInfo[id][ePosX], EventInfo[id][ePosY], EventInfo[id][ePosZ]);
SendClientMessage(playerid, NICESKY, string);
ePointCount++;
EventInfo[id][eCapturePlace] = CreatePickup(1274, 1, EventInfo[id][ePosX], EventInfo[id][ePosY], EventInfo[id][ePosZ]);
new labelstring[60];
format(labelstring, sizeof(labelstring), "Capture Point ID %d \n Prize: %s \n /claimpoint to claim the point", ePointCount, text);
EventInfo[id][eText] = Create3DTextLabel(labelstring, NICESKY, EventInfo[id][ePosX], EventInfo[id][ePosY], EventInfo[id][ePosZ], 15.0, -1, 0);
}
return 1;
}



command(claimpoint, playerid, params[])
{
new id = ePointCount;
if(IsPlayerInRangeOfPoint(playerid, 5.0, EventInfo[id][ePosX], EventInfo[id][ePosY], EventInfo[id][ePosZ]))
{
new string[128], name[24];
GetPlayerName(playerid, name, sizeof(name));
DestroyPickup(EventInfo[id][eCapturePlace]);
Delete3DTextLabel(EventInfo[id][eText]);
format(string, sizeof(string), "AdmWarning: %s has claimed Event Point ID %d", name, ePointCount);
SendToAdmins(ADMINORANGE, string, 1);
}
return 1;
}



So the problem is when I create the point with /createpoint, it's good, creating it, but the 3D Text is just dissapearing .... and only the icon stays ...
Also when I try to /claimpoint, nothing happens...

I havent created stocks to save them, because I don't want to, they are like mini - events.
P.S. please don't laugh on my script, it's my first system :D

MarTaTa
18/09/2012, 07:54 PM
Bump, anyone ? I realy need some help :(

Jessyy
19/09/2012, 03:46 PM
@MarTaTa ...
So the problem is when I create the point with /createpoint, it's good, creating it, but the 3D Text is just dissapearing .... and only the icon stays ...
To fix this problem is simple ... you must increase the "DrawDistance" (the distance from where you are able to see the 3D Text Label) [highlight with color RED]
Create3DTextLabel(text[], color, Float:X, Float:Y, Float:Z, Float:DrawDistance, virtualworld, testLOS)
From:
Create3DTextLabel(labelstring, NICESKY, EventInfo[id][ePosX], EventInfo[id][ePosY], EventInfo[id][ePosZ], 15.0, -1, 0);

To:
Create3DTextLabel(labelstring, NICESKY, EventInfo[id][ePosX], EventInfo[id][ePosY], EventInfo[id][ePosZ], 100.0, -1, 0);


From what i see you want to use the player interior ...

enum EventData
{
Float: ePosX,
Float: ePosY,
Float: ePosZ,
eVW,
eInterior,
Text3D: eText,
eCapturePlace
}

I recommend you to use "Streamer Plugin" by Incognito (http://forum.sa-mp.com/showthread.php?t=102865) ... to be able to use interior ...

Try this:
#define MAX_EVENT_POINTS 4

enum EventData {
Float: ePosX,
Float: ePosY,
Float: ePosZ,
eVW,
eInterior,
Text3D: eText,
eCapturePlace,
ePrize
}

new EventInfo[MAX_EVENT_POINTS][EventData], ePointCount = -1;

command(createpoint, playerid, params[])
{
if(Player[playerid][AdminLevel] < 2)
return 1;

new string[128],
prize,
id = (ePointCount += 1); //Equal: ePointCount++; id = ePointCount;

if(sscanf(params, "i", prize))
return SendClientMessage(playerid, NICESKY, "SYNTAX: /createpoint [prize/money/amount]");

new Float:x, Float:y, Float:z;
GetPlayerPos(playerid, x, y, z);
EventInfo[id][ePosX] = x;
EventInfo[id][ePosY] = y;
EventInfo[id][ePosZ] = z;
EventInfo[id][eVW] = GetPlayerVirtualWorld(playerid);
EventInfo[id][eInterior] = GetPlayerInterior(playerid);
EventInfo[id][ePrize] = prize;

format(string, sizeof(string), "Capture Point ID %d \n Prize: %d \n /claimpoint to claim the point", ePointCount, prize);
EventInfo[id][eText] = CreateDynamic3DTextLabel(string, NICESKY, EventInfo[id][ePosX], EventInfo[id][ePosY], EventInfo[id][ePosZ], 100.0, INVALID_PLAYER_ID, INVALID_VEHICLE_ID, 0, EventInfo[id][eVW], EventInfo[id][eInterior], -1, 100.0);

EventInfo[id][eCapturePlace] = CreateDynamicPickup(1274, 1, EventInfo[id][ePosX], EventInfo[id][ePosY], EventInfo[id][ePosZ], EventInfo[id][eVW], EventInfo[id][eInterior], -1, 100.0);

format(string, sizeof(string), "*Capture Point ID %d created at PosX(%.3f), PosY(%.3f), PosZ(%.3f)", ePointCount, EventInfo[id][ePosX], EventInfo[id][ePosY], EventInfo[id][ePosZ]);
SendClientMessage(playerid, NICESKY, string);
return 1;
}

command(claimpoint, playerid, params[])
{
new id = ePointCount;

if(id == -1) {
SendClientMessage(playerid, ADMINORANGE, "CLAIMPOINT: No capture point created");
return 1;
}

if(IsPlayerInRangeOfPoint(playerid, 7.0, EventInfo[id][ePosX], EventInfo[id][ePosY], EventInfo[id][ePosZ])) {
new string[128], name[24];
GetPlayerName(playerid, name, sizeof(name));

//The line below is a comment because I did not understand for what purpose is created players[to take take the prize]/admin [to remove the capture point] ???
//GivePlayerMoney(playerid, EventInfo[id][ePrize]);

DestroyDynamicPickup(EventInfo[id][eCapturePlace]);
DestroyDynamic3DTextLabel(EventInfo[id][eText]);

format(string, sizeof(string), "AdmWarning: %s has claimed Event Point ID %d", name, ePointCount);
SendToAdmins(ADMINORANGE, string, 1);

ePointCount -= 1; //Equal: ePointCount--;
}
else {
SendClientMessage(playerid, ADMINORANGE, "CLAIMPOINT: You must be in the last capture point created");
}

return 1;
}


- Changed: DrawDistance [15.0 to 100.0] for Create3DTextLabel
- Changed: "if(sscanf(params, "s", text))" to "if(sscanf(params, "i", prize))" *
- Changed: Create3DTextLabel & Create3DTextLabel for CreateDynamicPickup & CreateDynamic3DTextLabel (Streamer Plugin)
- Fixed: ePointCount, some issues in script returning invalid id
- Added: ability to check if are capture point created
- Added: ePrize to enum to know the price of capture point

*
Specifier(s) Name Example values
i, d Integer 1, 42, -10
c Character a, o, *
l Logical true, false
b Binary 01001, 0b1100
h, x Hex 1A, 0x23
o Octal 045 12
n Number 42, 0b010, 0xAC, 045
f Float 0.7, -99.5
g IEEE Float 0.7, -99.5, INFINITY, -INFINITY, NAN, NAN_E
u User name/id (bots and players) ******, 0
q Bot name/id ShopBot, 27
r Player name/id ******, 42


I hope that helps you out ...

MarTaTa
19/09/2012, 06:56 PM
Yes it realy helped me, one BIG THANK YOU !

Realy appreciated, REP + for you