switch failure? or am i stupid?
#1

Код:
forward switcher(playerid);
public switcher(playerid)
{
new
	a = 2;
switch (a)
{
	case 1:
	{
	Mode[playerid] = 1;
	SendClientMessage(playerid, COLOR_GREY, "MODE 1 MAC10");
	GivePlayerWeapon(playerid, 32,500);
	print("MODE SWITCHED to 1");
	}
	case 2:
	{
	Mode[playerid] = 2;
	SendClientMessage(playerid, COLOR_GREY, "MODE 1 SNIPER?");
	GivePlayerWeapon(playerid, 36,500);
	print("MODE SWITCHED to 2");
	}
	}
}
i want this switch to move back and forth, from 1 to 2, and so far it goes to two. and keeps reseting to number 2, i havnt scripted in a logn time, so... idea? broken? or am i an idiot?
Reply
#2

possibly need return 1;
Reply
#3

Tryed that, didnt work.
Reply
#4

I wouldn't know then, sorry man. I'm quite new to scripting still. Sorry!
Reply
#5

hey no problem, atleast you tryed. :P
Reply
#6

What are you trying to do?

Your code will always do this:
pawn Код:
Mode[playerid] = 2;
SendClientMessage(playerid, COLOR_GREY, "MODE 1 SNIPER?");
GivePlayerWeapon(playerid, 36,500);
print("MODE SWITCHED to 2");
Because "a" is always 2.
Reply
#7

im trying to switch them back and forth on a timer.
Reply
#8

I guess you need to label them "a" and 1 and 2.
Reply
#9

still not following
Reply
#10

I'm not sure how to do this, but what Miguel is trying to say, it is only choosing 2 because you placed (a = 2). If you replaced that 2 with a 1, it will only repeat mode 1. So if you try getting a to be both 1 and 2 or some crap, it'll do both.

I dont know if this is right, maybe I'm just blabbering
Reply
#11

Crayon, i think your a genious, holdon a second.
Reply
#12

Well, still cant get them to switch, but i got case 1 definded as a = 1. and case 2 as b = 2

how can i get these to rotate?
Reply
#13

pawn Код:
forward switcher(playerid);
public switcher(playerid)
{
    switch (Mode[playerid])
    {
        case 1:
            {
                Mode[playerid] = 2;
                SendClientMessage(playerid, COLOR_GREY, "MODE 1 MAC10");
                GivePlayerWeapon(playerid, 32,500);
                print("MODE SWITCHED to 1");
            }
        case 2:
            {
                Mode[playerid] = 1;
                SendClientMessage(playerid, COLOR_GREY, "MODE 1 SNIPER?");
                GivePlayerWeapon(playerid, 36,500);
                print("MODE SWITCHED to 2");
            }
        default: Mode[playerid] = 1;
    }
    return 1;
}
Reply
#14

You sir, i love you. i apriciate i <3
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)