Little help with code please?
#1

I have been making a DM server where we have little minigames of DM.
I have this code here but I want to make it where the two teams spawn at either side of the Jefferson Motel.


Here is my code.

I have these defined at the top if you will need them.
pawn Код:
#define TEAM_ALLIES 1
#define TEAM_AXIS 2
Now my code is this.
pawn Код:
if (strcmp("/jmd", cmdtext, true, 10) == 0)
    {
        new var2[24];
        new var4[256];
        GetPlayerName(playerid, var2, 24);
        format(var4, 256, "** %s has joined Jefferson Motel DM, Type /jmd to join", var2);
        SendClientMessageToAll(COLOR_RED, var4);
        new c = random(6);
        if (c == 0){
        // Side 1 (For Allies).
        SetPlayerPos(playerid, 2220.8215,-1149.4452,1025.7969);}
        else if (c == 1){
        SetPlayerPos(playerid, 2221.6023,-1139.9663,1027.7969);}
        else if (c == 2){
        SetPlayerPos(playerid, 2227.1799,-1141.6085,1029.7969);}
        else if (c == 3){
        SetPlayerPos(playerid, 2232.9680,-1150.1281,1029.7969);}
        else if (c == 3){
        // Side 2 (For Axis)
        SetPlayerPos(playerid, 2241.6462,-1192.2533,1029.7969);}
        else if (c == 4){
        SetPlayerPos(playerid, 2236.2317,-1188.6218,1029.8043);}
        else if (c == 5){
        SetPlayerPos(playerid, 2245.2378,-1186.0424,1029.8043);}
        SetPlayerInterior(playerid, 15);
        SetPlayerHealth(playerid, 100);
        SetPlayerArmour(playerid, 100);
        ResetPlayerWeapons(playerid);
        GivePlayerWeapon(playerid, 31, 1200);
        GivePlayerWeapon(playerid, 34, 1337);
        GivePlayerWeapon(playerid, 24, 1337);
        GivePlayerWeapon(playerid, 26, 500);
        SetPlayerVirtualWorld(playerid, 4);
        return 1;
    }
Reply
#2

And what is the problem?
Reply
#3

Quote:
Originally Posted by new121
Посмотреть сообщение
And what is the problem?
I thought I made that clear?
I guess not.


I have two teams.
I have 7 spawns in Jefferson Motel.

The first 4 spawns I want them to be used only for the Allies team when they type /jmd
The final 3 spawns I want them to be used only for the Axis team when they type /jmd

So when they are fighting, they don't spawn in the opposite teams area.
Reply
#4

do an if statement of their team if they in that team only put the spawns in the brackets.

Then do else
{
//other team spawns here
}
Reply
#5

Quote:
Originally Posted by KyleSmith
Посмотреть сообщение
do an if statement of their team if they in that team only put the spawns in the brackets.

Then do else
{
//other team spawns here
}
Could you possibly give me an example?
Reply
#6

Код:
if(gTeam[playerid] == 1) // TEAM RED
{
    // PUT SPAWNS HERE FOR THAT RED TEAM
}
else
{
    // PUT OTHER SPAWNS HERE FOR BLUE TEAM, NOT SAME SPAWNS AS RED.
}
Reply
#7

Quote:
Originally Posted by KyleSmith
Посмотреть сообщение
Код:
if(gTeam[playerid] == 1) // TEAM RED
{
    // PUT SPAWNS HERE FOR THAT RED TEAM
}
else
{
    // PUT OTHER SPAWNS HERE FOR BLUE TEAM, NOT SAME SPAWNS AS RED.
}
I'm not sure if this is what you mean?
However I have done this.


pawn Код:
if (strcmp("/jmd", cmdtext, true, 10) == 0)
    {
        new var2[24];
        new var4[256];
        GetPlayerName(playerid, var2, 24);
        format(var4, 256, "** %s has joined Jefferson Motel DM, Type /jmd to join", var2);
        SendClientMessageToAll(COLOR_RED, var4);
        new c = random(6);
        if(gTeam[playerid] == 1) // Allies
        {
        if (c == 0){
        SetPlayerPos(playerid, 2220.8215,-1149.4452,1025.7969);}
        else if (c == 1){
        SetPlayerPos(playerid, 2221.6023,-1139.9663,1027.7969);}
        else if (c == 2){
        SetPlayerPos(playerid, 2227.1799,-1141.6085,1029.7969);}
        else if (c == 3){
        SetPlayerPos(playerid, 2232.9680,-1150.1281,1029.7969);}
        }
        else // Axis
        {
        else if (c == 3){
        SetPlayerPos(playerid, 2241.6462,-1192.2533,1029.7969);}
        else if (c == 4){
        SetPlayerPos(playerid, 2236.2317,-1188.6218,1029.8043);}
        else if (c == 5){
        SetPlayerPos(playerid, 2245.2378,-1186.0424,1029.8043);}
        }
        SetPlayerInterior(playerid, 15);
        SetPlayerHealth(playerid, 100);
        SetPlayerArmour(playerid, 100);
        ResetPlayerWeapons(playerid);
        GivePlayerWeapon(playerid, 31, 1200);
        GivePlayerWeapon(playerid, 34, 1337);
        GivePlayerWeapon(playerid, 24, 1337);
        GivePlayerWeapon(playerid, 26, 500);
        SetPlayerVirtualWorld(playerid, 4);
        return 1;
    }
    return 0;
}
I get these errors.

Код:
C:\Users\John\Desktop\Script\gamemodes\Bayside.pwn(919) : error 029: invalid expression, assumed zero
C:\Users\John\Desktop\Script\gamemodes\Bayside.pwn(919) : warning 215: expression has no effect
C:\Users\John\Desktop\Script\gamemodes\Bayside.pwn(919) : error 001: expected token: ";", but found "if"
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


2 Errors.
Lines 917 - 921:
pawn Код:
else // Axis
        {
        else if (c == 3){
        SetPlayerPos(playerid, 2241.6462,-1192.2533,1029.7969);}
        else if (c == 4){
Reply
#8

Use this:

Quote:

if (strcmp("/jmd", cmdtext, true, 10) == 0)
{
new var2[24], var4[256];
GetPlayerName(playerid, var2, 24);
format(var4, 256, "** %s has joined Jefferson Motel DM, Type /jmd to join", var2);
SendClientMessageToAll(COLOR_RED, var4);
new c = random(6);
if(gTeam[playerid] == 1) // Allies
{
if (c == 0) SetPlayerPos(playerid, 2220.8215,-1149.4452,1025.7969);
else if (c == 1) SetPlayerPos(playerid, 2221.6023,-1139.9663,1027.7969);
else if (c == 2) SetPlayerPos(playerid, 2227.1799,-1141.6085,1029.7969);
else if (c == 3) SetPlayerPos(playerid, 2232.9680,-1150.1281,1029.7969);
}
else
{
if (c == 3) SetPlayerPos(playerid, 2241.6462,-1192.2533,1029.7969);
else if (c == 4) SetPlayerPos(playerid, 2236.2317,-1188.6218,1029.8043);
else if (c == 5) SetPlayerPos(playerid, 2245.2378,-1186.0424,1029.8043);
}
SetPlayerInterior(playerid, 15);
SetPlayerHealth(playerid, 100);
SetPlayerArmour(playerid, 100);
ResetPlayerWeapons(playerid);
GivePlayerWeapon(playerid, 31, 1200);
GivePlayerWeapon(playerid, 34, 1337);
GivePlayerWeapon(playerid, 24, 1337);
GivePlayerWeapon(playerid, 26, 500);
SetPlayerVirtualWorld(playerid, 4);
return 0;
}

Reply
#9

Quote:
Originally Posted by KyleSmith
Посмотреть сообщение
Use this:
Thanks Kyle!

I did it and it worked.

For some reason when I type /jmd it takes me to where I want but it also says SERVER: Unknown Command.
Reply
#10

Change return 0; to return 1; at the bottom.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)